Date:        Fri, 27 Apr 2018 16:20:01 +0200
    From:        Joerg Schilling <joerg.schill...@fokus.fraunhofer.de>
    Message-ID:  <5ae33191.adgpivkbwgx8dc1y%joerg.schill...@fokus.fraunhofer.de>

  | But you forgot that after this variable content is expanded, it is quoted 
in a 
  | way to keep the content in the final result.

I didn't forget that, because it doesn't happen.   That's what the

        bosh -c 'var="???";printf "%s\n" ${var}'

was meant to show.   The "???" is not kept in the final result,
it is expanded to produce all the 3 character filenames.

  | This however requires the macro 
  | expansion code (parameter expansion) to quote the \ at the end of the macro 
  | expansion to allow the \ to be kept visible after the final quote removal.

It doesn're require anything of the kind.   That \ is not subject to quote
removal, as it was not part of the original word.   Only quotes that were
in the original word get removed.   Sure, quoting it might be one way to
make that work, provided you can do it properly - but that does not
duplicae the original shell.

Remember, as you showed the code earlier, the original Bourne sh
parsed original word qouting by setting the QUOTE bit on the quoted
text.   Results of expansions don't get that.  Then quote removal is
just clearing that bit - it is all simple (and easy to code, and small,
which is why I assume it was done that way - despite all the idiotic
quoting rules it has left us with).

  | If this is not in the POSIX text,

It isn't, and should not be, as it is simply wrong.

The way the NetBSD sh (and original ash) copes with field splitting,
(and quote removal, or could, though that's actually done differently)
is by remembering (and updating as it changes) offsets into the word
to keep track of which chars are originals, and which are the results
of expansions.   The FreeBSD sh (which being based upon ash)
used to be the same, but they rewrote all of that part and now do it
a different way (but certainly not quoting the results of expansions).

kre


Reply via email to