Date:        Wed, 11 Apr 2018 12:18:27 +0100
    From:        Geoff Clare <g...@opengroup.org>
    Message-ID:  <20180411111827.GA29286@lt2.masqnet>

  | No, that text is very careful to say "*was* quoted", not "is quoted",
  | for precisely this reason.  To conform to this requirement, the shell
  | has to remember which characters were quoted when it removes the quotes.
  | How this is done is a matter for the implementor.

Yes, I saw that, but was quoted when?

Eg:

        var='!a'
        eval 'case b in *["$var"]*) echo match;;esac'

There in the case statement, everything "was" quoted once.

So that means we now are required to convert the case pattern to

        \*\[\!\a\]\*

does it?

It really is not  a good idea to try and craft minimal words that seem to 
achieve
the desired result - "was quoted" is just too vague.   Once again, after quote
removal, nothing is quoted.   When the code looked at the pattern, nothing was
quoted. Or it all was quoted.  Until you specify just what the "was" refers to.

There is nothing in the text that actually requires the implementation to do
what you suggest, because there's nothing to tell it how far back in time
that "was quoted" really means.   It might seem obvious to you, but
obvious to you isn't the right solution.

Beyond that, to get back to the example in the original message, once we
get past this "was quoted" stuff, we still need to deal with the later words
in the same sentence:

        and is not in a bracket expression is prefixed by a backslash

That is, in the (approximately) original example

        case b in ["$var"]) ...

the "was quoted" is irrelevant, either way, as this is in a bracket expression,
and so the \ is not added, and we end up with

        case b in [!a]) ...
not
        case b in [\!\a]

and even if we somehow interpret XBD 9.3.5 as allowing the latter to mean
a literal ! and a literal a are in the class (which is beyond stretching the
language, it is downright breaking it) it does not matter, as that is not
what we get, we get the former.

kre

Reply via email to