unshare01.sh: protect parameters expansion
PATCH 1/1 unshare01.sh: protect parameters expansion
The script passes around as args some strings with spaces using positional parameters: these are then in turn used unquoted to declare local function vars; this usage of 'local' together with the unquoted expansion is broken and leads to:
unshare_test()
{
local unshare_opts=$1
local verify_cmd=$2 <<<----124:...
case $1 in
unshare_test "--user" "id -u" "65534";;
....
unshare01.sh: 124: local: -u: bad variable name
This works fine on Bash but not on Dash (despite not being detected by checkbashism) and it is closely related to the use of 'local'; i.e. removing instead 'local' while leaving the unquoted expansion solves too.
Protect the positional parameter expansion with double quotes to prevent globbing and word splitting.
--- testcases/commands/unshare/unshare01.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
testcases/commands/unshare/unshare01.sh +9 -9
@@ -81,9 +81,9 @@ cleanup() check_id() { - local act_id=$1 - local exp_id=$2 - local cmd=$3 + local act_id="$1" + local exp_id="$2" + local cmd="$3" if [ ${act_id} -ne ${exp_id} ]; then tst_res TFAIL "$cmd got wrong uid/gid"
@@ -94,9 +94,9 @@ check_id() check_mount() { - local tst_dir=$1 - local exp_stat=$2 - local cmd=$3 + local tst_dir="$1" + local exp_stat="$2" + local cmd="$3" case ${exp_stat} in unmounted)
@@ -120,9 +120,9 @@ check_mount() unshare_test() { - local unshare_opts=$1 - local verify_cmd=$2 - local exp_result=$3 + local unshare_opts="$1" + local verify_cmd="$2" + local exp_result="$3" local unshare_cmd="unshare ${unshare_opts} ${verify_cmd}"
Signature · 1 line
2.17.1
PATCH 1/1 unshare01.sh: protect parameters expansion
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]