From a37489af79f19f06f328c91aba07f37756337f53 Mon Sep 17 00:00:00 2001 From: Emeric Verschuur Date: Sat, 30 Jun 2018 14:13:52 +0200 Subject: [PATCH] Fix enumeration type to support values with spaces --- bashopts.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bashopts.sh b/bashopts.sh index d8891ed..7ea6187 100644 --- a/bashopts.sh +++ b/bashopts.sh @@ -19,7 +19,7 @@ set -e -BASHOPTS_VERSION=2.1.0 +BASHOPTS_VERSION=2.1.1 bashopts_exit_handle() { local err=$? @@ -256,7 +256,7 @@ bashopts_declare() { -l) options[long_opt]=$1; shift;; -d) options[description]=$1; shift;; -t) options[type]=$1; shift;; - -e) options_enum_values+=($1); shift;; + -e) options_enum_values+=("$1");shift;; -m) options[method]=$1; shift;; -k) options[check]=$1; shift;; -s) options[setting]="true";; @@ -280,7 +280,7 @@ bashopts_declare() { if [ ${#options_enum_values[@]} -lt 2 ]; then bashopts_log C "bashopts_declare: ${options[name]} enumeration need at least two elements (two '-e ' calls at least)" fi - options[enum_values]="$(IFS=$'\n'; echo "${options_enum_values[*]}")" + options[enum_values]="$(printf "%s\n" "${options_enum_values[@]}")" ;; s|str|string) options[type]="string" -- GitLab