[Toybox] Would someone please explain what bash is doing here?

Chet Ramey chet.ramey at case.edu
Sun Mar 8 09:44:57 PDT 2020


On 3/8/20 10:53 AM, Rob Landley wrote:
>
> I read through the posix shell bits long enough ago it was probably SUSv3 rather
> than v4, but at the moment I'm taking bash as my standard and just doing
> whatever that does. 

Well, I appreciate that, but there just might be one or two places (or,
depending on who you talk to, one or two hundred) where bash diverges
from the standard. That might be because of bugs, or backwards
compatibility, or the standard having made a dumb decision.

And you can sometimes get into trouble for following the standard *too*
closely; cf. the issues with bash-5.0 treating an unquoted backslash as
subject to being removed by pathname expansion. The heated, lengthy
discussion that ensued eventually concluded that the plain text of the
standard -- which all agreed was what bash-5.0 implemented -- did not
reflect shell implementations or the original intent of the standard
developers, and that bash-4.4 implements the right way to do it.

That was not the first occurrence of that phenomenon.


> I should do another pass reading posix afterwards, but after
> https://landley.net/notes-2016.html#11-03-2016 I've been much less interested in
> interacting with the posix committee due to the risk of another Schilling, and
> have pretty much backed up to
> https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/ in much the same
> way Debian backed up to LSB 4.1 ala https://lwn.net/Articles/658809/

I gently recommend that you use the 2018 version of the standard; the group
did a lot of good work in those intervening years. That's the version I
shoot for.

I understand about Jorg. I'd like to be able to tell you to just ignore him
and listen to other voices, but I get that it's emotionally taxing and his
voice is loud enough to drown out others.


> 
> I still _sort_ of care about newer posix, but I got {bracket,expansion} working
> last year 

The group has discussed brace expansion. It's more or less a valid
extension not described by the standard.

> and last month taught my $IFS splitting to understand utf8 characters

? I don't think there's anything in POSIX that restricts IFS to single-
byte characters, since everywhere it refers to a "character" it's supposed
to be understood that a character can consist of multiple bytes. The
standard defines the term that way.

> (and have a TODO item that if IFS is an array it should understand strings), and
> I honestly don't expect to live long enough for either NOT to be a divergence
> from Posix.

I don't see POSIX ever standardizing arrays, and no conforming application
will ever expect IFS to be an array, so as long as you DTRT when IFS is a
string variable, you should be free to do whatever you like.

> Sorry to bother you, I should have (and eventually did) figure this out for myself.

No bother.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet at case.edu    http://tiswww.cwru.edu/~chet/


More information about the Toybox mailing list