On 23/12/2014 23:34, Vadim Zeitlin wrote:
Hello, I'm not exactly sure if this is a bug because I didn't find any specification about how is this supposed to behave (to my surprise it turned out that $_ was not in POSIX), but please consider this: % zsh -c 'echo -n foo && echo $_' foofoo % bash -c 'echo -n foo && echo $_' foofoo % dash -c 'echo -n foo && echo $_' foo/usr/bin/dash
This does come across as somewhat confusing, but $_ is really not a special variable at all in dash. The shell you're using to launch dash does make it a special variable. That shell puts _ in the environment, which dash then picks up, and ignores, other than making it available as $_.
You can see what your usual shell is doing by testing with other commands: just run
env | grep '^_=' and you'll probably see _=/usr/bin/env It works the same way when starting dash.
I've tested several different versions of zsh (4 and 5) and bash (3 and 4) and dash 0.5.5 and 0.5.7 from Debian and they all produced the results as above. Shouldn't dash follow the other shells here? VZ
If dash did something special with $_, then I agree it would be nice if it would be somewhat compatible with other shells. If dash simply does not implement a feature, that feature is not required by any standard, and that feature is not widely used, then I suspect there won't be a lot of interest in implementing that feature.
Don't be put off by that, though. You are free, of course, if you feel so, to attempt to convince people $_ is an important feature that all shells should implement. If you have compelling use cases, if it solves real problems, and if many other shells already implement it, you might even get it standardised. I have never seen a need for it, but that's just me speaking from personal experience, others may feel differently.
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