1. 21
  1.  

  2. 5

    Nice article. In a similar vein and possibly helpful to others, I made this a while ago while dealing with bash quirks: bash-script-template. Idea was to have a sane starting point for creating more complex scripts that needed to be somewhat durable, with sane scripting defaults.

    It provides several functions I’d often find myself effectively writing whenever I started a new script, hence the creation of a template I can simply source, or edit if I want it to be entirely self-contained. Might be useful to others, and constructive criticism is always welcome!

    1. 4

      This is way too much for what I normally write, but a lot of it looks useful! I’ll definitely be picking and choosing pieces from this for my scripts. Thanks!

      1. 2

        If you’re writing anything more than a couple of lines, take ten minutes to set up the “shellcheck” linter. It’ll tell you what could go wrong, line by line, and how to fix it.

        I’ve found it elevates the reliability of my shell scripts to be comparable to my ruby.

        1. 1

          Shellcheck is great. I use it day-to-day and during the creation of those templates :)