bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No tilde expansion right after a quotation


From: Eric Blake
Subject: Re: No tilde expansion right after a quotation
Date: Mon, 16 Feb 2009 05:53:56 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.6.666

-----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             ebb9@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-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]