[sf-lug] > and >> and < and << and |
Rick Moen
rick at linuxmafia.com
Mon Aug 8 21:28:11 PDT 2016
Quoting Alex Kleider (akleider at sonic.net):
> interesting.
> Under what circumstances would someone with both installed wish to
> use dash rather than bash?
dash (Debian Almquist SHell), a close variant of NetBSD's Almquist shell
(/bin/ash), is much smaller than bash, much faster, and less featureful.
E.g., dash usually compiles to about 100kB, bash to about 900kB. It's
fully but minimally POSIX-compliant, and thus _should_ be usable
anywhere a Bourne-compatible shell is called for, e.g., any script where
the shebang line invokes '#!/bin/sh'.
So, (1) _if_ shell scripts that have #!/bin/sh as the shebang invocation
were written correctly, most particularly avoiding bashisms, then making
/bin/sh be a link to /bin/dash will greatly improve their performance
relative to /bin/sh pointing to /bin/bash, and (all other things being
equal) should improve system security.
Some distros do that; others don't.
https://en.wikipedia.org/wiki/Almquist_shell
The ones that did it are basically the ones that went through the effort
of finding and eliminating bashisms from system scripts that were never
supposed to have any in the first place. The ones that didn't are those
in denial about inappropriate bashisms (***COUGH*** Red Hat ***COUGH***)
and haven't yet cleaned up their acts.
(2) For the same reason, the root user's shell ought to always be a POSIX
shell, so that user's shell ought to be /bin/dash (whether /bin/sh
points there or not).
(3) Irrespective of the previous two things, you might be writing a
Bourne script devoid of bashisms. If so, it's in your interest to use
#!/bin/dash as the shebang, so your script will run more quickly with less
RAM.
(Perl script checkbashisms can parse your existing /bin/sh scripts and
scold you over any bashisms.
http://www.cyberciti.biz/faq/debian-ubuntu-linux-binbash-vs-bindash-vs-binshshell/
https://wiki.archlinux.org/index.php/Dash
https://wiki.debian.org/DashAsBinSh
https://wiki.ubuntu.com/DashAsBinSh
https://www.wikivs.com/wiki/Bash_vs_dash
https://lwn.net/Articles/343924/
More information about the sf-lug
mailing list