[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: quote nesting bug
From: |
Chet Ramey |
Subject: |
Re: quote nesting bug |
Date: |
Sat, 20 Nov 2010 16:59:01 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2 |
On 11/19/10 1:20 PM, Matt Zyzik wrote:
> bug-bash,
>
> I am noticing a behavior that appears to be a bug. Additionally, what I
> am expecting to happen is the actual behavior in both Zsh and Ksh.
>
> This is the command (ignore leading whitespace):
> echo "${fpbnoinervzkjeh:-'good morning}"
> This is the output in both Zsh and Ksh (ignore leading whitespace):
> 'good morning
In bash, nested quotes within dollar-bracket expansions introduce a new
quoting context, and bash requires that the quotes be matched. This is
in effect whether or not the expansion is enclosed in double quotes.
That is how I interpreted these portions of Posix:
"Within the string of characters from an enclosed "${" to the
matching '}', an even number of unescaped double-quotes or single-
quotes, if any, shall occur."
and
"The matching closing brace shall be determined by counting brace
levels, skipping over enclosed quoted strings, and command
substitutions."
There was a discussion about this on the Posix working group mailing
list last spring, and the first quote above was deemed a requirement
on the application, not the shell, and the second was discarded as
"completely wrong." The result was an interpretation that declared
that single quotes have no special meaning within expansions enclosed
in double quotes.
Bash-4.2 will change Posix mode to comply with the new Posix
interpretation. By default, it will behave as it always has.
Chet
--
``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/