Shell script best practices, from a decade of scripting things
&gt; Use bash. Using zsh or fish or any other, will make it hard for others to understand &#x2F; collaborate. Among all shells, bash strikes a good balance between portability and DX.<p>I think fish is quite a bit different in terms of syntax and semantics (I&#x27;m not very familiar with it), but zsh is essentially the same as bash except without most of the needless footguns and awkwardness. zsh also has many more advanced features, which you don&#x27;t need to use (and many people are unaware of them anyway), but will very quickly become useful; in bash all sorts of things require obscure incantations and&#x2F;or shell pipelines that almost make APL seem obvious in comparison.<p>In my experience few people understand bash (or POSIX sh) in the first place, partly because everything is so difficult and full of caveats. Half my professional shell scripting experience on the job is fixing other people&#x27;s scripts. So might as well use something that doesn&#x27;t accidentally introduce bugs every other line.<p>Most – though obviously far from all – scripts tend to be run in environments you control; portability is often overrated and not all that important (except when it is of course). Once upon a time I insisted on POSIX sh, and then I realised that actually, &gt;90% of the scripts I wrote were run just by me or run only in an environment otherwise under my control, and that it made no sense. I still use POSIX sh for some public things I write, when it makes sense, but that&#x27;s fairly rare.<p>I think bash is really standing in the way of progress, whether that progress is in the form of fish, zsh, oil shell, or something else, because so many people conflate &quot;shell&quot; with &quot;bash&quot;, similar to how people conflate &quot;Google&quot; with &quot;search&quot; or &quot;git&quot; with &quot;GitHub&quot; (to some degree).