Showing 4 posts
As most programming languages with support for functions, the shell offers locally-scoped variables. Unfortunately, local variables are not the default. You must explicitly declare variables as local and you should be very strict about doing this to prevent subtle but hard-to-diagnose bugs. That’s it! What else is there to say about this trivial keyword? As it turns out, more than you might think.
March 13, 2018
·
Tags:
<a href="/tags/readability">readability</a>, <a href="/tags/shell">shell</a>
Continue reading (about
5 minutes)
Some programming languages have a feature known as strict mode: a setting that makes the language interpreter disallow certain obviously-broken code that would otherwise work. The simplest examples are JavaScript and Perl but, as it turns out, the shell also has something akin to this feature. The “strict mode” name, however, is unofficial, so you won’t find many references to it online. You can enable the shell’s strict mode by doing one of the following:
March 9, 2018
·
Tags:
<a href="/tags/featured">featured</a>, <a href="/tags/readability">readability</a>, <a href="/tags/shell">shell</a>
Continue reading (about
6 minutes)
The shell supports defining functions, which, as we learned in the previous post, you should embrace and use. Unfortunately, they are fairly primitive and their use can, paradoxically, introduce other readability problems. One specific problem is that function parameters are numbered, not named, so the risk of cryptic code is high. Let’s see why this is a problem.
March 2, 2018
·
Tags:
<a href="/tags/readability">readability</a>, <a href="/tags/shell">shell</a>, <a href="/tags/shtk">shtk</a>
Continue reading (about
3 minutes)
Our team develops Bazel, a Java-based tool. We do have, however, a significant amount of shell scripting. The percentage is small at only 3.6% of our codebase… but given the size of our project, that’s about 130,000 lines—a lot, really. Pretty much nobody likes writing these integration tests in shell. Leaving aside that our infrastructure is clunky, the real problem is that the team at large is not familiar with writing shell per se. Few people are these days actually.
February 26, 2018
·
Tags:
<a href="/tags/readability">readability</a>, <a href="/tags/shell">shell</a>, <a href="/tags/shtk">shtk</a>
Continue reading (about
2 minutes)