Christoph Anton Mitterer wrote, on 21 Feb 2022:
>
> On Mon, 2022-02-21 at 09:58 +0000, Geoff Clare via austin-group-l at
> The Open Group wrote:
> > The reason the LC_ALL=C is needed to avoid unspecified behaviour is
> > because the description of the ${parameter%[word]} expansion refers
> > to 2.13 for how the pattern matching is done, and 2.13 is worded
> > entirely in terms of characters.
>
> Well not exactly, as far as I can see:
>
> 2.13 itself (i.e. without sub-chapters) doesn't even contain the word
> character and instead says:
>
> "The pattern matching notation described in this section is used to
> specify patterns for matching STRINGS in the shell."
>
>
> 3.375 String defines:
> "A contiguous sequence of bytes terminated by and including the first
> null byte."
>
>
> Only 2.13.1 and .2 talks all about characters.
>
>
> Not sure whether I miss anything obvious, but that's what I meant in my
> previous mail:
> - Is the "string" in 2.13 simply wrong?
Since all character strings are strings, it is not wrong per se.
However, it could be changed to say "character strings" without
altering the requirements.
> - If not, could one imply from the (byte) "string" in 2.13 upon which
> the characters from 2.13.1/.2 are matched, that these need to ignore
> any non-character bytes.
> => Which, I assume, is what Thomas had in mind?
> - Or perhaps simply that it mustn't be applied on any (byte) strings
> that contain non-character?
Neither. If there are non-character bytes in the string then the
behaviour is simply unspecified, because 2.13.1 and 2.13.2 don't
specify how they are handled.
This is why I was careful to say "needed to avoid unspecified behaviour"
in my previous email.
> The standard even compares with fnmatch(), which would also operate on
> C-strings.
The behaviour of fnmatch() when there are non-character bytes in
the string is also unspecified, because it again refers to 2.13.1
and 2.13.2 for how the matching is done.
--
Geoff Clare <[email protected]>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England