[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
posix vs default mode nonsense
From: |
Zachary Santer |
Subject: |
posix vs default mode nonsense |
Date: |
Mon, 21 Oct 2024 00:15:41 -0400 |
Was "'wait -n' with and without id arguments"
On Sun, Oct 20, 2024 at 10:30 PM Grisha Levit <grishalevit@gmail.com> wrote:
>
>
> On Sun, Oct 20, 2024, 20:52 Zachary Santer <zsanter@gmail.com> 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:
>
> $ 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.
I took "defined to perform pattern removal" as specific to
${parameter#pattern} and ${parameter%pattern},so I thought quote
removal wouldn't be performed on 'pattern' and 'replacement' in
${parameter//pattern/replacement} in POSIX mode. I could've tested
that, but I didn't. Replacing 'pattern' with 'replacement' is also
removing 'pattern', isn't it?
I'll admit that it surprises me that regular quote removal isn't
performed on 'word' in stuff like ${parameter:+word}, but whatever.
Not going to argue with all shells.
On Sun, Oct 20, 2024 at 10:49 PM Lawrence Velázquez <vq@larryv.me> wrote:
>
> On Sun, Oct 20, 2024, at 8:51 PM, 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?
> >
> > Item 3 is also a weird thing to do
>
> Neither of these is "odd" or "weird". They are consistent with
> other shells and specified by POSIX. (Debating the requirement
> would be even more tedious than the rest of this conversation,
> and this isn't the proper forum besides.)
"Tedious" is the word.
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. I will keep POSIX
mode in mind for when I'm playing with at least bash 5.1.
- 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 <=
- Re: posix vs default mode nonsense, Chet Ramey, 2024/10/21
- 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