Portable Shell Scripts
A fair share of small utilities that allow one to generate a simple static website and an RSS feed will satisfy most lads' needs; however, if one's website has already been written and designed from scratch, tweaking the source code of a certain utility is nearly inevitable, and one is more than likely going to end up rewriting the whole project to suit their preferences.
The biggest flaw of a huge portion of such tools is that they heavily rely on various dependencies, and in cases when said tools are written in command languages, people usually choose bash, as virtually every GNU/Linux distribution comes pre-installed with it. Despite numerous bugs as well as a set of security holes bash has had over the years, the language is solid and fun to program in. The issue here is that even if programs written in bash may not rely on any dependencies, they, for the most part, will be using bashisms instead, which is a big dependency by itself.
what is the solution, then?
There is no ultimate answer to this question, but I would always prefer to utilise POSIX-compliant scripts for the sake of portability and execution speed. Bash would suffice as an interactive shell, but it will be much slower as a non-interactive shell in comparison to ash, for instance.
but bash is a fully fledged command language that supports plenty of features a proper language should have!
While this is technically true, one can easily implement arrays or process substitution in a way that conforms POSIX specification. Most features one would expect from bash or any other modern shell can be done in a portable way, and if one wants to write a complex program that exceeds 150-200 lines of code with numerous bells and whistles, an appropriate programming language could be used in this case instead.
why shall portability be of concern to me in the first quarter of the twenty-first century? the 1980s have long gone!
Because not everyone uses GNU/Linux; those who do, however,
grow to become dependent on GNU extensions of coreutils
and other utilities, such as grep
, awk
,
sed
and so on, that will break the program on
non-GNU/Linux operating systems. If you give zero fucks about your
scripts being portable, then who am I to impose my opinion on you? Carry
on, I guess.