On Monday 27 September 2010 12:52:02 Stephen Gildea wrote: > Using the "local" command to do variable assignment should not do word > splitting. The following script shows how a Dash function incorrectly > handles an argument with a space in it.
Dash is actually working as expected: 'local' is a built-in and as any other built-in or command, when you don't quote a variable it is expanded: count() { echo got $# } show_buggy_word_splitting() { local d=$1 # think of: count d="$1" count d=$1 if [ "$d" = "two words" ]; then echo Success return 0 else echo Failure return 1 fi } show_buggy_word_splitting "two words" Bash and others treat 'local' (just like export, etc) differently, but it's a known shell portability issue. Another example: special_expansion() { echo Quoted: export ex="$1" env | grep words echo Unquoted: export ex=$1 env | grep words } special_expansion "two words=foo" $ dash /tmp/t.sh Quoted: ex=two words=foo Unquoted: words=foo $ bash /tmp/t.sh Quoted: ex=two words=foo Unquoted: ex=two words=foo Cheers, -- Raphael Geissert - Debian Developer www.debian.org - get.debian.net -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org