[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash tries to parse comsub in quoted PE pattern
From: |
Chet Ramey |
Subject: |
Re: bash tries to parse comsub in quoted PE pattern |
Date: |
Wed, 18 Oct 2023 10:50:54 -0400 |
User-agent: |
Mozilla Thunderbird |
On 10/18/23 10:24 AM, Emanuele Torre wrote:
On Wed, Oct 18, 2023 at 09:50:00AM -0400, Chet Ramey wrote:
On 10/17/23 5:55 PM, Emanuele Torre wrote:
braces.c
- brace_gobbler: use extract_dollar_brace_string if we see ${ with
the appropriate value of QUOTING, so we don't have to teach brace
expansion more shell syntax.
Report from Emanuele Torre <torreemanuele6@gmail.com>
- brace_gobbler: call the word extraction functions with SX_NOALLOC
so we don't have to allocate memory we're just going to free
That patch fixed the bug with "${foo#'$('}", but it also broke the
"${arr["{start..end}"]}" / "${arr["{foo,bar}"]}" patterns.
How much shell syntax do you want? You want brace expansion to detect
some issues with parameter expansion but ignore others, and detect
some expansions but not others, without supplying requirements.
I didn't even think that the "${foo#'$('}" had something to do with
brace expansion.
OK, now you know, and now you know where the fix needs to be applied.
Now I am reporting that the patch that was supposed to fix that problem
It does fix the reported problem. You can't fully consume shell word
expansions without parsing them as word expansions, and you can't avoid
the reported problem without parsing the word expansion.
made "${foo["{2,1}"]}" no longer expands to "${foo["2"]}" "${foo["1"]}".
Hence my point: to fix the reported problem, you have to parse the word
expansion, since simple quoted string skipping doesn't do it. To allow
this syntax, you cannot parse the word expansion.
Brace expansion between "${foo[" and "]}" is something that has always
worked: at least since bash 2.05b (I have not checked with earlier
versions after the introduction of arrays).
Is it really ok to break that behaviour?
That's why, if you want the first problem repaired, you have to specify
which word expansions are ok to parse and which are not. Should it be
only command and process substitution, which can independently specify
brace expansions? Should it be other parameter expansions, which can
contain quoted strings and command substitutions? Neither? Both?
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- Re: bash tries to parse comsub in quoted PE pattern, (continued)
- Re: bash tries to parse comsub in quoted PE pattern, Chet Ramey, 2023/10/18
- Re: bash tries to parse comsub in quoted PE pattern, Emanuele Torre, 2023/10/18
- Re: bash tries to parse comsub in quoted PE pattern,
Chet Ramey <=
- Re: bash tries to parse comsub in quoted PE pattern, Chet Ramey, 2023/10/18
- Re: bash tries to parse comsub in quoted PE pattern, Emanuele Torre, 2023/10/18
- Re: bash tries to parse comsub in quoted PE pattern, Chet Ramey, 2023/10/19
- Re: bash tries to parse comsub in quoted PE pattern, Emanuele Torre, 2023/10/21