[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: posix vs default mode nonsense
From: |
Chet Ramey |
Subject: |
Re: posix vs default mode nonsense |
Date: |
Mon, 21 Oct 2024 11:50:36 -0400 |
User-agent: |
Mozilla Thunderbird |
On 10/21/24 12:15 AM, Zachary Santer wrote:
Item 8 is just odd and is on the verge of being a dealbreaker. Not to
go off on another tangent, but what on Earth?
AFAICT it's the non-POSIX-mode Bash behavior that is unusual.
While all shells will have treat single quotes as literal here:
$ V=set
$ echo "${V+'x'}"
'x'
Pretty much every other shell (and bash in posix mode) will continue to do so
for:
$ echo "${V+'x}"
'x
...while bash will treat this as an unterminated command. Because in bash,
this is a weird kind of quoting, where the quotes are preserved but any }
character within them loses its special meaning:
The original POSIX language dating from 1992, and through three editions,
required an even number of single quotes, which made them semi-special:
"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."
See https://www.austingroupbugs.net/view.php?id=221 for the results of
the discussion that prompted this change. Most of the talking took place
on the mailing list. Good times.
This changed in 2010, by which we had over 20 years of the original
behavior (and the interpretation was approved in 2010, but not in an
issued version of the standard until 2016).
$ unset U
$ (set +o posix; echo "${U+'}'y}")
$ (set -o posix; echo "${U+'}'y}")
'y}
I misinterpreted Item 8, then.
POSIX file:
8. When parsing and expanding a ${...} expansion that appears within
double quotes, single quotes are no longer special and cannot be
used to quote a closing brace or other special character, unless
the operator is one of those defined to perform pattern removal.
In this case, they do not have to appear as matched pairs.
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_02_03
The current standard language says "substring processing." Bash can
do whatever it wants with pattern substitution.
The nontrivial stuff I do is still being run by bash 4.2 at the
moment, and I'm not willing to give up procsubs.
Probably something to take up with your distro (Red Hat/Centos, right?)
--
``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/
OpenPGP_signature.asc
Description: OpenPGP digital signature
- Re: 'wait -n' with and without id arguments, Chet Ramey, 2024/10/17
- Re: 'wait -n' with and without id arguments, Zachary Santer, 2024/10/20
- Re: 'wait -n' with and without id arguments, Grisha Levit, 2024/10/20
- posix vs default mode nonsense, Zachary Santer, 2024/10/21
- Re: posix vs default mode nonsense,
Chet Ramey <=
- Re: posix vs default mode nonsense, Zachary Santer, 2024/10/21
- Re: posix vs default mode nonsense, Lawrence Velázquez, 2024/10/21
- Re: posix vs default mode nonsense, Zachary Santer, 2024/10/21
- Re: posix vs default mode nonsense, Chet Ramey, 2024/10/22
- Re: posix vs default mode nonsense, Zachary Santer, 2024/10/25
- Re: posix vs default mode nonsense, Chet Ramey, 2024/10/26
- Re: posix vs default mode nonsense, Robert Elz, 2024/10/21
- Re: posix vs default mode nonsense, Chet Ramey, 2024/10/21
- Re: 'wait -n' with and without id arguments, Lawrence Velázquez, 2024/10/20
- Re: 'wait -n' with and without id arguments, Chet Ramey, 2024/10/21