[Top][All Lists]

[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: Gecko/20081209 Thunderbird/ Mnenhy/

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:

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             address@hidden
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


reply via email to

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