3 ms·
Shell scripting is absolutely still relevant. The rule of thumb should not be about length but about complexity, specifically if you absolutely need something l
by roryrjb 7y ago
Shell scripting is absolutely still relevant. The rule of thumb should not be about length but about complexity, specifically if you absolutely need something like a real array or a hash then move onto a different language. Use shellcheck and avoid bash for scripting. I use bash or pdksh interactively but stick to POSIX shell for scripting. I am finding myself writing POSIX shell all the time and having great success with it.
- gameswithgo 7y agoit is, but should it be?
- pletnes 7y agoWhy not bash? It’s in most places, even if POSIX is even more general. And it does add some nice scripting features. I use zsh for interactive and bash for scripts for the same reasons as you, though.
- smichel17 7y agoBecause when you find yourself needing bash-specific features, alarm bells should be going off. POSIX sh is good at reminding you to KISS and delegate to other tools.
- fiddlerwoaroof 7y agoI write my scripts in zsh, because its extensions are most useful in scripts, and it’s not too hard just to make it available everywhere you need to work (e.g. you can compile it to be installed in ~/zsh and just copy the installation to your home directory on any machine you need to use. Things like array-linked variables ($path is an array version of $PATH and modifications to one propagate to the other), associative arrays (dictionaries in python) and a handful of other really nice tools (e.g. saner white space handling) make going back to bash for scripts unpleasant.
- roryrjb 7y agoYeah don't get me wrong the bashisms are useful, but I'm hopping between OpenBSD, FreeBSD and Linux (and perhaps sharing scripts with my macOS-using colleagues) and although bash is available on all those platforms and more, POSIX shell will work out of the box without any further configuration.
- JdeBP 7y agoSo you're switching among the Debian Almquist, Bourne Again, FreeBSD Almquist, PD Korn, and Z shells. Surely you could find some way of working the Watanabe, MirBSD Korn, BusyBox Almquist, and Mashey shells into the mix, too? (-: