Bashing the Bash – Replacing Shell Scripts with Python (2017)
I was <i>hoping</i> someone finally had a library or something to make python good at the things shell does well (mostly, running stuff and piping output around). If only.<p>This really just reads like someone who doesn&#x27;t know shell and does know python, but thinks the problem is the tool. They continually describe shell with phrases like &quot;obscure and difficult-to-predict&quot; while talking through things that are either obvious with experience or from context, and then write something <i>different</i> in python (i.e. something you <i>could</i> write in BASH that does something different) that&#x27;s not less obscure but is only using <i>python</i> obscurity.<p>&gt; An example of a shell obscurity is the way the current working directory is set. The cd command is clear enough, but in the presence of sub-shells using (), can make it difficult to discern a stack of nested shell invocations and how the working directory changes when the sub-shells exit.<p>Er... yeah? So you expect PWD to be a global and it was actually a local?<p>Or more explicitly:<p>&gt; One of the shell’s ickier features is that variables tend to be global. There are some exceptions and caveats, however, that lead to shell scripts that are broken or behave inconsistently.<p>That&#x27;s not a shell feature, that&#x27;s just how people frequently write it - you can make functions and declare your variables local if you want. I can easily write a python script with all my variables at the top, too.