3 ms·
Thank you for sharing this; I infrequently have to write standalone shell scripts but every time I do I spend a while looking around for best practices and ofte
by RossM 8y ago
Thank you for sharing this; I infrequently have to write standalone shell scripts but every time I do I spend a while looking around for best practices and often just end up with some contradicting opinions.
- moviuro 8y agoI usually refer to http://mywiki.wooledge.org/BashFAQ http://mywiki.wooledge.org/BashFAQ , which is what anyone on #bash IRC channel would recommend. Good luck!
- m0nty 8y agoThere's also this: https://news.ycombinator.com/item?id=6866085 https://news.ycombinator.com/item?id=6866085 And the Google 'Shell Style Guide': https://google.github.io/styleguide/shell.xml https://google.github.io/styleguide/shell.xml Just in case you hadn't seen them already.
- moviuro 8y agoJust for the record, the Google guide focuses on Google infrastructure and systems, not portability. Using /bin/bash for instance is not a good idea if you want to port your work to BSD systems.
- richardwhiuk 8y agoWhich you probably don't care about.
- stephenr 8y agoBash isn't even a good choice if you want to support just macOS and Linux, because the versions available are so wildly different.
- jsjohnst 8y ago1) supporting both macOS and Linux in bash is trivial. Just stick to Bash 3 functionality. 2) Bash4 is trivial to install on macOS via home brew, so saying “available” is a misnomer. “Default” would be a bit better, but many Linux distros still in use don’t use Bash4. 3) Bash 3 vs 4 isn’t “wildly” different.