3 ms·
Am I understanding correctly that your point is that we shouldn't write modern bash scripts because some number of untrained people will have problems by accide
by fooblat 6y ago
Am I understanding correctly that your point is that we shouldn't write modern bash scripts because some number of untrained people will have problems by accidentally misusing the scripts (wrong interpreter, blind copy/paste, etc). Is that a correct summary?
To me this sounds like saying we shouldn't have powerful tools like chainsaws because every year some people without safety training use them wrong and hurt themselves.
- dataflow 6y agoNo, that's just an exaggerated caricature of what I'm saying. I'm only saying you should avoid using modern things needlessly. This means, don't do it when the POSIX-compliant syntax also serves your needs. e.g., don't do [[ -f "$foo" ]] when you could just as easily do [ -f "$foo" ]. And if you do need to use Bash-specific features, make sure it's safe enough that foreseeable misuses will fail safely. Or when that's not possible, try to mitigate it somehow (maybe with a comment, or by putting in some extra dynamic checks, or other solutions you can think of). And this goes for other things too, not just Bash. Probably outside programming too.
- fooblat 6y ago> I'm only saying you should avoid using modern things needlessly. I agree with that idea. However, I don't think it applies in this case. The point of using modern bash syntax is that it fixed the brittleness and pitfalls of posix sh. This is significant. This is what I need in production. This is why our style guides insist on modern bash syntax for bash scripting. I'd say the rest of your suggestions apply to shell scripts no matter what syntax is used.