[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pattern substitution expands "~" even in quoted variables
From: |
Chet Ramey |
Subject: |
Re: pattern substitution expands "~" even in quoted variables |
Date: |
Sun, 09 Mar 2014 13:51:38 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 3/9/14, 3:16 AM, Mike Frysinger wrote:
> On Fri 07 Mar 2014 16:15:05 Eduardo A. Bustamante López wrote:
>> address@hidden:~$ for shell in /bin/bash ~/local/bin/bash; do "$shell" -c
>> 'p=foo_bar; echo "${p/_/\~} $BASH_VERSION"'; done
>> foo\~bar 4.2.37(1)-release
>> foo~bar 4.3.0(2)-release
>
> you can get same behavior in <=bash-4.2 and >=bash-4.3 by using single quotes:
> P="foo_bar"
> MY_P=${P/_/'~'}
> echo "${MY_P}"
Yes, only the behavior when in double quotes changed.
- --
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlMcqiIACgkQu1hp8GTqdKvMEQCfdHS9nEIi5WxTJxG2cDlSKAKM
5gQAmwQ8hyD5uVNxF5H1JhkNJ2wXJonP
=uLio
-----END PGP SIGNATURE-----