On 27/03/2018 11:44, Herbert Xu wrote:
On Tue, Mar 27, 2018 at 11:16:29AM +0200, Harald van Dijk wrote:
If you say that quote removal takes place on the original token (meaning
before parameter expansion), and if parameter expansion takes place before
pathname expansion, then there's nothing left to allow \* to behave
differently from *.
Either you misunderstood me or you misread POSIX.
I misunderstood you. Given v='\' and the word \\$v, I took the result of
parameter expansion as \\\ where the first two backslashes come from the
original word, you take the result of parameter expansion as only \.
Because of that, when you wrote quote removal is never applied to the
results of parameter expansion, I didn't see what you meant. I think
you're right in your terminology, the result of parameter expansion is
just \, to get \\\ it would need to be phrased as something like "the
result of applying parameter expansion". Thanks for the clarification.
POSIX never actually says this optimisation is allowed. The only thing that
allows it is the fact that it produces the same results anyway. If that
stops, then checking the file system for matches becomes required.
It doesn't disallow it either.
If POSIX specifies a result, and a shell applies an optimisation that
causes a different result to be produced, doesn't that inherently
disallow that optimisation? There may be some confusion and/or
disagreement over what exactly POSIX specifies and/or intends to
specify, but I don't see how you can argue that POSIX specifies result
A, but it's okay to apply an optimisation that produces result B.
Can you show me a shell that doesn't apply this optimisation?
Can you show me any shell other than bash that lets this optimisation
affect the results?
Like I wrote in my initial message, all other shells I tested take a
backslash that comes from a variable after parameter expansion as
effectively quoted. Given your b="/*/\null", bash is the only shell I
know that expands $b to /dev/null. All others do perform pathname
expansion, but check to see if a file \null exists in any top-level
directory.
Given a="/de[v]/\null" and b="/dev/\null", all shells other than bash,
even dash, agree that $a and $b expand to '/dev/\null' if that file
exists, or the original string if that file doesn't exist. *That* is
what allows the optimisation in the case of $b: expanding to either
'/dev/\null' or '/dev/\null', depending on some condition, can be done
without evaluating that condition.
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