On 04/10/2014 06:53 AM, Jeff Cody wrote: >>> +++ b/tests/qemu-iotests/common.rc >>> @@ -178,10 +178,10 @@ _rm_test_img() >>> local img=$1 >> >> Since we are quoting $img, should we quote $1 as well? >> > > I believe not, because variable assignment won't undergo all the shell > expansions. Notably, in variable assignment word splitting is not > performed on the parameter expansion on the argument immediately to the > right of the '='. Quote removal, however, will still be performed. So > img=$1 and img="$1" are identical once processed. Ooh, tricky. You are correct that in isolation: img=$1 img="$1" are semantically identical, no matter what $1 contains, across ALL shells. However, that's not the code you wrote above. local img=$1 is not POSIX (yet - although there has been some effort in the POSIX working group to standardize some form of local variables while still allowing for the fact that bash and ksh implemented scoping of local variables differently). But 'local' is similar to 'export'; and observe the difference when using 'export' between dash and bash: $ dash -c 'set "a b"; export a=$1 b="$1"; echo "$a.$b"' a.a b $ bash -c 'set "a b"; export a=$1 b="$1"; echo "$a.$b"' a b.a b Here, the shell word a=$1 is semantically NOT a raw assignment, but rather an argument to 'export', and arguments DO undergo word splitting in the current wording of POSIX. There was a recent bug report stating that the dash behavior (which is strictly POSIX) is undesirable, and that the bash/ksh behavior of export, while not strictly compliant with the POSIX 2008 wording, is nicer; so the next version of POSIX will be amended to add a definition of a 'declaration utility' which can evaluate (some) arguments in assignment context. 'export' is one such declaration utility, 'local' (if it gets standardized) would be another: http://austingroupbugs.net/view.php?id=351 But even with the notion of an assignment-context argument added to a future version of POSIX, the reality is that given the present standard, it's safer to either use "" to ensure no word splitting: local img="$1" or to rewrite things across two statements to avoid relying on whether assignment-context arguments work the way you want: local img img=$1 -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org