On 26/02/2018 09:40, Harald van Dijk wrote:
On 26/02/2018 08:03, Harald van Dijk wrote:
On 2/13/18 2:53 PM, Denys Vlasenko wrote:
$ >'\zzzz'
$ >'\wwww'
$ dash -c 'echo "\*"'
\wwww \zzzz
There's another case where this goes wrong, that isn't fixed by your,
my, or Herbert's patches:
And hopefully I've got a good example now:
$ touch '\www'
$ src/dash -c 'x=\\*a y=*a z=\\*; printf "%s\n" ${x#$z} ${y#$z} $z'
\*a
a
\www
In both $z and ${x#$z} / ${y#$z}, $z is unquoted. In $z, it's
interpreted as a literal backslash followed by a * wildcard. In ${x#$z},
it's interpreted as an escaped * character. I don't understand why these
cases should be treated differently.
ksh agrees with dash.
bash also behaves strangely here. In both cases, it treats the * as
escaped by the preceding backslash, but in $z, the backslash is
preserved, whereas in ${x#$z} / ${y#$z}, the backslash is removed:
$ bash -c 'x=\\*a y=*a z=\\*; printf "%s\n" ${x#$z} ${y#$z} $z'
\*a
a
\*
posh is more consistent: in both $z and in ${x#$z} / ${y#$z}, $z is
treated as a literal backslash followed by a * wildcard:
$ posh -c 'x=\\*a y=*a z=\\*; printf "%s\n" ${x#$z} ${y#$z} $z'
*a
*a
\www
I'm having trouble telling from the spec what the expected behaviour is
here, and because of that, whether dash's behaviour is already correct
or needs to be modified.
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