5 ms·
>Why BASH instead of another programming language? >Is the default shell for all OSs except for Windows BSD users would very much disagree, as would embedded
by networked 13y ago
>Why BASH instead of another programming language?
>Is the default shell for all OSs except for Windows
BSD users would very much disagree, as would embedded Linux users and others. In fact, this assumption is a very common cause of portability problems for free and open source software.
I'm as guilty as anyone of assuming every shell is bash but when I had to make my software compile and run tests on both Linux and FreeBSD straight out of the repository I discovered that targeting the POSIX shell was not as limiting as you might think. I have since made it a habit to avoid "bashisms" in most scripts; a good way to start with that is to learn what is and isn't a bashism using a handy list found at http://mywiki.wooledge.org/Bashism http://mywiki.wooledge.org/Bashism.
- Avshalom 13y agoI don't think it's true of anything but OSX and most desktop linux-en. Solaris, hp-ux, AIX use(d) ksh, QNX too I think.
- mitchty 13y agoEven for OSX its kinda iffy as statements go. I think (been a while now) tcsh was the default for < 10.3, 10.3 was zsh and maybe 10.4, then it moved to /bin/bash as default shell.
- jrajav 13y agoI think it's safe to wash <= 10.3 at this point, it has less than 0.01% market share. Most stat gatherers have actually stopped tracking anything below 10.4 or 10.5. Also, I didn't know that zsh was ever the default? I thought it switched from tcsh to bash around 10.3 or 10.4.
- UNIXgod 13y agoIt was zsh emulating csh. they messed up by not using the almquist shell like the other BSDs.
- mitchty 13y agozsh was only in I think 10.4 or 10.3, hard to tell anymore as I don't have any ppc machines to install any old os's on any longer. Just giving historical context, not trying to say anything about markeshare or anything. Apple seems really willing to change shells is basically all my post amounts to.
- mitchty 13y agoSo I have an old copy of Mac OS X for Unix Geeks here. 10.2 was tcsh, 10.3 was tcsh for user shells and /bin/sh for scripts. I think 10.4 was the zsh experiment, then 10.5+ bash. We'll see how long bash lasts being a gpl shell.
- frou_dh 13y agoI wish there was a linter to check shell scripts for non-POSIX syntax and command invocations. I'm put off trying to really grok *sh scripting because the landscape seems a bit of a confusing mess.
- deleted 13y ago[deleted]
- networked 13y agoGive checkbashisms a look. You can install it on Debian and its derivatives with sudo apt-get install devscripts Edit: It's a bit hard to find a current checkbashisms version on the Web (the one on SourceForge is an abandoned fork of an older version), so I've uploaded a recent stable one to http://pastebin.com/Ncu6DRuM http://pastebin.com/Ncu6DRuM. If you're not on Debian and decide to keep it clone git://anonscm.debian.org/collab-maint/devscripts.git.
- frou_dh 13y agoThank you - I'm checking it out.
- profquail 13y agoAgreed. Many/most of the shell scripts I've ever seen using 'bash' could be using the standard 'sh' instead; most need no changes at all, and the rest need just a few minor tweaks to eliminate non-POSIX-compliant behavior. Since Debian and other distros now use the BSD-licensed `dash` as their default system shell (system, not user) I suspect they've become more motivated to reduce unnecessary bashisms in shell scripts. Debian's 'devscripts'[1] project includes a Perl script called 'checkbashisms'[2] which you can use to detect many of these common 'bashisms'. For those of you running Ubuntu, you can install 'devscripts' with apt-get: sudo apt-get install devscripts For those of you running FreeBSD, you can install 'devscripts' from the devel/devscripts port. [1]: http://packages.qa.debian.org/d/devscripts.html http://packages.qa.debian.org/d/devscripts.html [2]: http://anonscm.debian.org/gitweb/?p=collab-maint/devscripts.git;a=blob;f=scripts/checkbashisms.pl;h=81fbaba38da6620642d8a062d7483644d3a87a86;hb=HEAD http://anonscm.debian.org/gitweb/?p=collab-maint/devscripts....
- e40 13y agoEven if not the default shell on BSD, is bash available (by default)?
- clarry 13y agoIt can be installed via ports or packages.
- tedunangst 13y agoBy default, no. Installable, yes. Installed in /bin/bash? No as well. Don't start portable scripts with #!/bin/bash.