Joerg Schilling <joerg.schill...@fokus.fraunhofer.de> wrote, on 27 Jun 2019:
>
> Stephane Chazelas <stephane.chaze...@gmail.com> wrote:
> 
> > Today, by your reading of the spec and I agree it can be seen as
> > a valid reading, the spec is telling me that:
> >
> > 1.
> >
> > a='\.'
> > printf '%s\n' $a
> >
> > is a portable script that is meant to output "."
> 
> I know just one single shell that outputs "." with this code.
> 
> This is bash5. Note that POSIX is a portable source standard and other shells
> that may behave like bash5 currently only compile and work on a single 
> platform.
> 
> My impression is that this is mainly supported by Geoff

That was my initial position, but we have moved on since then.  I am
willing to accept the compromise currently being discussed whereby
pathname expansion only happens when there is an unquoted '*', '?'
or '[' in the pattern, in which case the above would be required
to output '\.'  I updated the proposal in the etherpad accordingly.

> > 2.
> >
> > a='\**'
> > printf '%s\n' $a
> >
> > is a portable script that is meant to list the filenames that
> > start with "*" in the current directory
> 
> See 1), there is just one shell that behaves this way.

And that shell is "bash" (not just "bash5").  All versions I tried do
it (including bash3 on macOS).

> > 1 and 2 is the reason I raised bug 1234. 1 couldn't be furthest
> > away from the truth. Only bash5 exhibits that behaviour and it's
> > evident it's a bad idea. It's evident that it was not the
> > intention of the spec as no shell at the time it was written did
> 
> This is very important, as POSIX does not claim to do own invention.

This is simply not true in the case of POSIX.2-1992, and I have
corrected you on that before.  POSIX.2-1992 deliberately made a number
requirements that forced implementations to change, including some
that were invention (an obvious one being pax).

> > 2 is slightly more portable, but even in those shells where it
> > does that, that's not because they implement \ processing the
> > way POSIX seems to specify it, and all do it a different way.
> > I'm not opposing POSIX *allows* a \ in an unquoted word
> > expansion to have a special meaning when it's preceding *, ? and
> > [ as that's what several implementations do and it's not
> > breaking that many common shell usages.
> 
> I see no real difference to 1). The only portable shell that behaves this way 
> is bash5.

No, all versions of bash back to at least 3.2 behave that way.

-- 
Geoff Clare <g.cl...@opengroup.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

Reply via email to