5 ms·
The google shell style uses bash which is not portable, one of the main point of the OP article.
by pmarin 10y ago
The google shell style uses bash which is not portable, one of the main point of the OP article.
- nailer 10y agoBash is the default shell on the most popular server nix (Linux) and the most desktop nix (OS X, though it's always a slightly old version). If you use OpenBSD and hate ports, then maybe ignore all the good things bash brings and write everything in Bourne shell. If not, then write bash. Just fire it up with '/usr/bin/env bash' to label it correctly.
- deleted 10y ago[deleted]
- Someone 10y ago"OS X, though it's always a slightly old version" Apple ships the last version that had a GPL2 license. That version gets older by a day every day. On OS X 10.11.2, it seems to be bash 3.2 (http://opensource.apple.com/source/bash/bash-99/ http://opensource.apple.com/source/bash/bash-99/, via http://opensource.apple.com/release/os-x-10112/ http://opensource.apple.com/release/os-x-10112/), which is from October 12, 2006 (https://lists.gnu.org/archive/html/info-gnu/2006-10/msg00006.html https://lists.gnu.org/archive/html/info-gnu/2006-10/msg00006...) I wouldn't call that slightly old.
- JdeBP 10y ago> Bash is the default shell Not for nigh on a decade, now. * https://wiki.ubuntu.com/DashAsBinSh https://wiki.ubuntu.com/DashAsBinSh * https://wiki.ubuntu.com/DashAsBinSh/Spec https://wiki.ubuntu.com/DashAsBinSh/Spec * https://lists.debian.org/debian-release/2007/07/msg00027.html https://lists.debian.org/debian-release/2007/07/msg00027.htm... * https://wiki.debian.org/DashAsBinSh https://wiki.debian.org/DashAsBinSh
- nailer 10y agoBourne shell being replaced as /bin/sh by dash doesn't change anything: Linux and OSX don't use /bin/sh as the default shell.
- JdeBP 10y ago> Linux and OSX don't use /bin/sh as the default shell. You didn't even read the first sentence of the first hyperlinked page.
- the_why_of_y 10y agoI believe xe meant "default login shell". Also, "Bourne Again shell", while we're complaining about missing words :-)
- nailer 10y agoMy username is nailer not xe, but you're right, I meant default login shell when I wrote 'default shell', rather than what bin sh is linked to. Even if bin sh links to bash, bash will still run a bin sh script in Bourne shell mode, stripping newer features, in some cases. Hence why proper scripts alway specify bash explicitly. However I meant Bourne shell when I wrote 'ignore all the good things bash brings and write everything in Bourne shell.' Bourne shell being the original /bin/sh (though it's murky).
- JdeBP 10y agoXe would have been a bit daft to mean that, given the headline topic as well as that the conversation so far has dealt in shell scripts and shell script interpreters, to which the choice of login shell is almost wholly irrelevant.
- nailer 10y agoYes I did. Proper shell scripts specify their actual shell - ie, bash scripts use bash as their interpreter. Your linked article mentions this explicitly. Do, again: whether bin sh is Bourne or Dash doesn't change anything, because a properly written script will specify its interpreter.
- mixedCase 10y ago>If you use OpenBSD and hate ports, then maybe ignore all the good things bash brings and write everything in Bourne shell. If not, then write bash. If Bourne is not comfortable or powerful enough for the task you're trying to do, you're using the wrong tool and Python is probably what you should be using.
- nailer 10y agoYeah I'd do most systems work in Python too, but bash has some useful safety options in shopt, some neat syntax items like ..., arithmetic subshells, etc. which can make it fine for basic scripts. I guess you think Bourne shell -> Python depending on complexity. I think bash -> Python depending on complexity.
- mixedCase 10y ago>which can make it fine for basic scripts. As long as it's for your own system administration, sure. The moment it's being used for software intended to be used by third parties, no, the niceties of bash over bsh are not worth it.