From 203cdf990858601b04121c1d7de65c314418f156 Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Fri, 21 Sep 2018 11:21:05 +0200 Subject: [PATCH] TT#44516 Fix quoting logic for script 'set' for values like '10G' It was impossible to set value like '10G' previosuly: >> ngcpcfg set /etc/ngcp-config/config.yml bootenv.netscript.fallbackfssize=10M > Bareword found where operator expected at /tmp/tmp.px3MpkUFZS line 28, near "10M" > (Missing operator before M?) > Bareword found where operator expected at /tmp/tmp.px3MpkUFZS line 30, near "10M" > (Missing operator before M?) > Bareword found where operator expected at /tmp/tmp.px3MpkUFZS line 31, near "10M" > (Missing operator before M?) > Bareword found where operator expected at /tmp/tmp.px3MpkUFZS line 33, near "10M" > (Missing operator before M?) > Bareword found where operator expected at /tmp/tmp.px3MpkUFZS line 34, near "10M" > (Missing operator before M?) > syntax error at /tmp/tmp.px3MpkUFZS line 28, near "10M" > syntax error at /tmp/tmp.px3MpkUFZS line 30, near "10M" > syntax error at /tmp/tmp.px3MpkUFZS line 39, near "}" > Execution of /tmp/tmp.px3MpkUFZS aborted due to compilation errors. The 'case' statement doesn't support regular expresions in Bash, let's rewrite them into linear check. Change-Id: I29ced837fca0abdc3cbe1ea18c614c4c1dd6780c --- scripts/set | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/set b/scripts/set index 4c6c587d..93af3767 100755 --- a/scripts/set +++ b/scripts/set @@ -44,17 +44,15 @@ log_debug "Saving option '${option}' value '${value}' into '${file}'" if [[ ${value} =~ ^\'.*\'$ ]] ; then log_debug "\$value is already quoted." +elif [[ ${value} =~ ^[0-9]*$ ]] ; then + log_debug "Not quoting \$value for integers." +elif [[ ${value} =~ ^\[.*\]$ ]] ; then + log_debug "Not quoting \$value for arrays." +elif [[ ${value} =~ ^\{.*\}$ ]] ; then + log_debug "Not quoting \$value for hashes." else - log_debug "\$value is NOT quoted, doing so if necessary." - case ${value} in - [0-9]*|\[*\]|\{*\}) - log_debug "Do not quoting \$value for integers, arrays and hashes." - ;; - *) - log_debug "Quoting \$value to prevent further Perl errors." - value="\"${value}\"" - ;; - esac + log_debug "Quoting \$value to prevent further Perl errors." + value="\"${value}\"" fi tmp=$(mktemp)