In 'Bash Considered Pointless', Chad Perrin considers a few obvious points about bash:
1) That if you care about maximum portability across Unix-like systems, you shouldn't use bash. (Use sh.)
2) That if you care about maximum simplicity of code, you shouldn't use bash. (Use sh. Or better yet, rc!)
3) That if you care about maximum customizability of the shell environment, you shouldn't use bash. (Use zsh. Never use fish, however.)
4) That if you care about maximum performance, you shouldn't use bash. (Use (m)ksh or (d)ash.)
And given the recent discovery that there's been a veritable termite mound just underneath the floorboards of bash all this time, we can add: if you care about security, you shouldn't use bash.
That said, what principled reason could anyone possibly have to use bash? I can't think of any, which makes it look like a classic case of arbitrary market lockin -- somebody decided that bash was the standard shell for Linux distros, and bash is not so obviously awful as to foster great discontent among any but the most picky of operators. Until now, anyway: in light of the bashdoor discovery, there have been some murmurings that Fedora might move away from bash to mksh or dash, which would hopefully be the beginning of a stampede. One can dream, anyway.
Anyway, Chad makes another, more philosophical point that I find interesting: he thinks an interactive shell should be optimized to be an interactive shell and a programming language should be optimized to be a programming language, and that bash scripting falls rather inelegantly between these two stools -- or rather, is frequently abused to do things that should be done in a proper programming language. This point made me think of two things at once.
The first thing was Erik Naggum's infamous take on Perl: 'it's not that perl programmers are idiots, it's that the language rewards idiotic behavior'. But since Perl was pretty much made to 'correct' the deficiencies of shell scripting, it strikes me that all of Naggum's criticism applies in a suitably weaker form to that domain, as well. I don't have quite the same raging hate-on for Perl, but I see his point and think that any script that gets longer that a dozen lines or so should probably be redone in a proper programming language. It may in fact be a bad idea to make the shell too powerful, in which case anything more featureful than rc is probably harmful in the long run. (Seeing people seriously suggest patching bash with Perl is a confirmation of Naggum's worldview, and would be comical if it wasn't tragic.)
The second thing it made me think of is, of course, the Lisp REPL, which I think is a good counterexample to Chad's general thesis -- in an old Symbolics Lisp machine, there was no shell because there was no distinction between the command interface and the language the OS was written in. This strikes me as nirvana for the intelligent operator. Sadly, the last remnant of this principle still in use today is ... Emacs. Which, for other arbitrary historical reasons, is not a particularly inspiring exemplar.
In any case, please, whatever you do, stop using bash. Use zsh if you like big and baroque, use mksh/dash if you like small and snappy, or use sh/rc if you're truly hardcore. Just migrate to something else. Do it today. Do it now. You might like it!
No comments:
Post a Comment