by ymse · 10y ago · 0 comments
I've started using #!/usr/bin/env bash for compatibility with non-FHS distros such as NixOS.
Happy to see arrays omitted; if you find yourself in need of bash arrays you should definitely consider a proper language.
I tend to stick to POSIX shell to the extent possible, but readonly variables and [[ ]] syntactic sugar makes sense when maintainability is more important than portability.
> Executables must start with #!/bin/bash
Either they never use *BSD, or they put their bash there. Unbelievable choice.
> If you find you need to use arrays for anything more than assignment of ${PIPESTATUS}, you should use
I use array all the time and never used PIPESTATUS. So what?
Bash arrays can be convenient, but at that level of complexity Python or Ruby are much easier to read and understand (and necessarily maintain).
We run everything on prodimage, so operating system compatibility isn't really an issue.
Realistically, any time somebody sends me a code review with a shell script in it, my first comment is going to be "Why is this a shell script? Rewrite it in a supported language."
pretty much