bug-bash
[Top][All Lists]
Advanced

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

Re: Unexpected behavior of single quotes when used in the patsub PE.


From: Chet Ramey
Subject: Re: Unexpected behavior of single quotes when used in the patsub PE.
Date: Wed, 20 Mar 2013 21:15:24 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130216 Thunderbird/17.0.3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/20/13 5:56 PM, Eduardo A. Bustamante López wrote:

> Bash Version: 4.3
> Patch Level: 0
> Release Status: alpha
> 
> Description:
>   The rules for escaping single quotes inside the
>   pat and rep arguments are somehow fuzzy. There's a difference
>   between what I expected to work, and how really bash treats strings
>   there.

You're correct that this specific behavior changed between bash-4.2 and
bash-4.3.  There was extensive discussion of this point on bug-bash,
starting with

http://lists.gnu.org/archive/html/bug-bash/2012-02/msg00106.html

That resulted in the change, which is documented in the CHANGES file in
bash-4.3-alpha (as well as COMPAT and in the change log):

zz. When using the pattern substitution word expansion, bash now runs the
    replacement string through quote removal, since it allows quotes in that
    string to act as escape characters.  This is not backwards compatible, so
    it can be disabled by setting the bash compatibility mode to 4.2.

That change is described in the section of the man page that covers the
`compat42' shell option.

>   I see that that specific PE has changed in every bash major
>   version, and even within minor releases it has incompatible
>   behavior.

You say that, but you don't provide any actual evidence to back is up.
The behavior with this expansion was the same from bash-3.1 (as far back
as I went) through bash-4.2.

>   I include a script that -- I expect -- explains the issue better
>   than my words. The left side of the `|' is what bash generates, the
>   right side is what I expect.

Thanks for the script.  I will look at the fix for the bad substitution
error (I suspect your fix is not correct because the code should not treat
single quotes as special when parsing a double-quoted string, and the
error message is printed elsewhere).

Chet

- -- 
``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/

iEYEARECAAYFAlFKXyUACgkQu1hp8GTqdKsGygCghSkLLCjoJsi738/NnLDTejDW
C2QAnjL1RisKOGvlLJnhSxBNPSSM02BT
=SjNR
-----END PGP SIGNATURE-----



reply via email to

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