bug-bash
[Top][All Lists]
Advanced

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

Re: Inconsistent quote and escape handling in substitution part of param


From: Chet Ramey
Subject: Re: Inconsistent quote and escape handling in substitution part of parameter expansions.
Date: Tue, 28 Feb 2012 08:36:40 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0

On 2/28/12 4:17 AM, lhunath@lyndir.com wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: i386
> OS: darwin11.2.0
> Compiler: /Developer/usr/bin/clang
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
> -DCONF_OSTYPE='darwin11.2.0' -DCONF_MACHTYPE='i386-apple-darwin11.2.0' 
> -DCONF_VENDOR='apple' -DLOCALEDIR='/opt/local/share/locale' -DPACKAGE='bash' 
> -DSHELL -DHAVE_CONFIG_H -DMACOSX   -I.  -I. -I./include -I./lib  
> -I/opt/local/include -pipe -O2 -arch x86_64
> uname output: Darwin mbillemo.lin-k.net 11.3.0 Darwin Kernel Version 11.3.0: 
> Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
> Machine Type: i386-apple-darwin11.2.0
> 
> Bash Version: 4.2
> Patch Level: 20
> Release Status: release
> 
> Description:
>       The handling of backslash and quotes is completely inconsistent, 
> counter-intuitive and in violation of how the syntax works elsewhere in bash.
> 
>     ' appears to introduce a single-quoted context and \ appears to escape 
> special characters.  That's good.
>     A substitution pattern of ' causes bash to be unable to find the closing 
> quote.  That's good.
>     A substitution pattern of '' SHOULD equal an empty quoted string.  The 
> result, however, is ''.  That's NOT good.  Suddenly the quotes are literal?
>     A substitution pattern of '$var' SHOULD disable expansion inside the 
> quotes. The result, however, is '[contents-of-var]'.  That's NOT good.  In 
> fact, it looks like quoting doesn't work here at all.
>     \\ is a disabled backslash, and the syntactical backslash is removed.  
> The result is \.  That's good.
>     \' is a disabled single quote, but the syntactical backslash is NOT 
> removed.  The result is \'.  That's NOT good.
>     
>     It mostly looks like all the rules for handling quoting and escaping are 
> out the window and some random and utterly inconsistent set of rules is being 
> applied instead.
> 
> Fix:
>       Change parsing of the substitution pattern so that it abides by all the 
> standard documented rules regarding quotes and escaping.

It would go better if you gave some examples of what you consider
incorrect behavior.  This description isn't helpful as it stands.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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