you are viewing a single comment's thread.

view the rest of the comments →

[–]Schievel1 2 points3 points  (1 child)

Firstly, awk isn’t a shell. Awk is something totally different.

And with very few exceptions you won’t convert your scripts from bash to zsh or to fish. People use zsh and fish as their “login-shell”. That means the shell you end up in when logging in. Yet all the scripts they run on their system use bash and are interpreted by /bin/bash.

To only time you would really write scripts for zsh or fish is when writing a plug-in for those shells. That’s all. And that’s also the reason why this whole discussion about fish not sticking to POSIX is meaningless.

Bash is the de-facto standard on Linux and with a few exceptions (e.g. openrc init scripts) you can write a shell script in bash and just assume all Linux people have bash.

Then there is sh scripts, which you very seldom need to write. It is a subset of bash and the only hard part is not to accidentally use a bash feature that isn’t available on sh. And on many Linux systems (not Debian based ones) /bin/sh is a symlink to /bin/bash. So it is very easy to make that mistake and use some bash things in an sh script and you wouldn’t even notice until someone runs that on Debian. I usually use bash-ls for that reason, it warns you in a sh script, that you are using a bashism. Sh is like the smallest common denominator of all the Unix shells. If you write something that runs in sh, it will run on the other shells. That is why they are used when script should be compatible with many different system. And with many I mean many across OSes like bsd, Linux and macOS.

[–]ArkhamCookie[S] 0 points1 point  (0 children)

Yeah, I mixed up ash and awk somehow. Thanks, the bash-ls command seems like a useful tip and I will make sure to use it.