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: Sun, 15 Feb 2009 21:32:06 -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/15/2009 3:02 PM:
> I tried CPATH="${CPATH}${CPATH:+:}"~usr1/blah/blah.  (I quote 
> expansions just to be on the safe side, though I think home directories may 
> not contain spaces.)

There are some contexts, such as variable assignments, where double quotes
are not necessary.

foo='a b'
bar=$foo

is just as safe as

bar="$foo"

In fact, it is MORE portable to avoid double quotes in assignments, if you
are worried about writing scripts portable to more than just bash.  Of
these two constructs:

foo="`echo "a b"`"
bar=`echo "a b"`

only the setting of bar is guaranteed to parse correctly in all shells.

- --
Don't work too hard, make some time for fun as well!

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

iEYEARECAAYFAkmY7EYACgkQ84KuGfSFAYAmlwCgn5o87vKmCfyvi95ILDQ/1dD0
C/wAn1WRWAeh4eUghCNYLBLMSiU+j9vq
=jFAM
-----END PGP SIGNATURE-----




reply via email to

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