News for hackers. Stuff that matters.
Re:BASH as a Modern Programming Language [ppt] by networked on Saturday December 07, 2013 @08:39AM (#6866336)
>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.

Re:BASH as a Modern Programming Language [ppt] by profquail on Saturday December 07, 2013 @10:20AM (#6866562)
Agreed. 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

[2]: http://anonscm.debian.org/gitweb/?p=collab-maint/devscripts....

Re:BASH as a Modern Programming Language [ppt] by poobrains on Sunday December 08, 2013 @12:16PM (#6870275)
There's no FreeBSD port called "devscripts", perhaps you meant devel/checkbashisms
Re:BASH as a Modern Programming Language [ppt] by profquail on Sunday December 08, 2013 @01:48PM (#6870757)
You're absolutely correct, the port is devel/checkbashisms. My mistake.

https://www.freshports.org/devel/checkbashisms/

Re:BASH as a Modern Programming Language [ppt] by frou_dh on Saturday December 07, 2013 @10:10AM (#6866528)
I 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.

Re:BASH as a Modern Programming Language [ppt] by networked on Saturday December 07, 2013 @10:16AM (#6866555)
Give 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. If you're not on Debian and decide to keep it clone git://anonscm.debian.org/collab-maint/devscripts.git.
Re:BASH as a Modern Programming Language [ppt] by frou_dh on Saturday December 07, 2013 @10:52AM (#6866645)
Thank you - I'm checking it out.
Re:BASH as a Modern Programming Language [ppt] by Avshalom on Saturday December 07, 2013 @09:05AM (#6866378)
I 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.
Re:BASH as a Modern Programming Language [ppt] by mitchty on Saturday December 07, 2013 @11:21AM (#6866737)
Even 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.
Re:BASH as a Modern Programming Language [ppt] by jrajav on Saturday December 07, 2013 @11:50AM (#6866823)
I 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.

Re:BASH as a Modern Programming Language [ppt] by mitchty on Monday December 09, 2013 @12:08AM (#6872885)
So 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.

Re:BASH as a Modern Programming Language [ppt] by mitchty on Sunday December 08, 2013 @08:55PM (#6872494)
zsh 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.

Re:BASH as a Modern Programming Language [ppt] by UNIXgod on Saturday December 07, 2013 @12:29PM (#6866930)
It was zsh emulating csh. they messed up by not using the almquist shell like the other BSDs.
Re:BASH as a Modern Programming Language [ppt] by e40 on Saturday December 07, 2013 @12:44PM (#6866985)
Even if not the default shell on BSD, is bash available (by default)?
Re:BASH as a Modern Programming Language [ppt] by tedunangst on Saturday December 07, 2013 @01:08PM (#6867059)
By default, no. Installable, yes.

Installed in /bin/bash? No as well. Don't start portable scripts with #!/bin/bash.

Re:BASH as a Modern Programming Language [ppt] by clarry on Saturday December 07, 2013 @12:49PM (#6866997)
It can be installed via ports or packages.