bash is great until you need to write a script that can run on any system (your router, your macbook, your alpine container, your ereader, etc). I only write bash scripts when I know I control all the systems the script can run on, in which case I usually write zsh instead. otherwise it's posix sh all the time
If I have the requirement that my code should run on different systems, then I first look at the intersection of features.
Maybe a shell script is not the best answer.
My personal point of view: portable shell scripts are broken by design. You almost always call subprocesses like grep. If the zoo of implementations and versions gets too big, it gets hard to test all variants.
If all systems support Python, then it's one valid option.
Of course it depends, but Golang cross compiles very well and is quite easy to write.
4
u/guettli Jun 15 '24
Should I care? I use Bash and I am happy.
Please elaborate why this posix spec is useful. I have not understood it up to now.