On 26/03/2018 13:57, Martijn Dekker wrote:
Op 26-03-18 om 12:30 schreef Harald van Dijk:
With the snipping it's not clear that I was specifically confused by the
inconsistency.
I had included another example:
pat="/de\v"
printf "%s\n" $pat
I can understand treating backslash as quoted, or treating it as
unquoted, but not quoted-unless-in-a-case-statement. What justifies this
one exception?
I don't see any inconsistency. Expansions are consistently treated
differently within 'case' than outside it. Among other things,
expansions within 'case' are *not* subject to pathname expansion; it's
string pattern matching using glob patterns, which is something
completely different.
It's not something completely different. Pathname expansion is defined
in terms of pattern matching (the pattern matching used in e.g. case
statements), plus a specific set of differences. See 2.6.6 Pathname
Expansion:
After field splitting, if set -f is not in effect, each field in the resulting command line shall be expanded using the algorithm described in Pattern Matching Notation, qualified by the rules in Patterns Used for Filename Expansion.
That specific set of differences, 2.13.3 Patterns Used for Filename
Expansion, doesn't include different treatment of backslashes.
Cheers,
Harald van Dijk
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html