-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Angel Tsankov on 2/16/2009 2:26 AM: >> There are some contexts, such as variable assignments, where double >> quotes are not necessary. >> >> foo="`echo "a b"`" >> bar=`echo "a b"` >> >> only the setting of bar is guaranteed to parse correctly in all >> shells. > Eric, thanks for youy replay. If double quotes are not that portable, then > how am I suppose to assign the output from some command to a variable when > the output contains a space?
The portability bug I am referring to is the use of double-quoted back-ticks containing a double quote. Some (buggy) shells require you to use \" instead of " inside backticks if the overall backtick expression is double-quoted. So finding contexts where word splitting does not occur (such as variable assignment and case statements) and avoiding double quotes in those particular contexts makes it easier to write arbitrary backtick expressions. For more details, see: http://www.gnu.org/software/autoconf/manual/autoconf.html#Shell-Substitutions But besides the "`""`" bug, double quotes are safe in all contexts, and you are free to use them even in contexts where they add no protection. - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkmZYeQACgkQ84KuGfSFAYBPzQCgq2vkBd6o6QtVzcUKsTUTsA/N qgQAoJadvlYysc9SiWm9VeLp+S+hFOz6 =AiK6 -----END PGP SIGNATURE-----