[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 16:05:14 -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 12:26 PM, John Kearney wrote:
> But that isn't how it behaves.
> "${test//str/"dddd"}"
>
> because str is replaced with '"dddd"' as such it is treating the double
> quotes as string literals.
>
> however at the same time these literal double quotes escape/quote a
> single quote between them.
> As such they are treated both as literals and as quotes as such
> inconsistently.
I don't have a lot of time today, but I'm going to try and answer bits
and pieces of this discussion.
Yes, bash opens a new `quoting context' (for lack of a better term) inside
${}. Posix used to require it, though after lively discussion it turned
into "well, we said that but it's clearly not what we meant."
There are a couple of places in the currently-published version of the
standard, minus any corregendia, that specify this. The description of
${parameter} reads, in part,
"The matching closing brace shall be determined by counting brace levels,
skipping over enclosed quoted strings, and command substitutions."
The section on double quotes reads, in part:
"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."
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/
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., (continued)
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Chet Ramey, 2012/02/29
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Maarten Billemont, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Steven W. Orr, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions.,
Chet Ramey <=
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Chet Ramey, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Chet Ramey, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Chet Ramey, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Maarten Billemont, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Chet Ramey, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Chet Ramey, 2012/02/28