bug-bash
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]