“Exit Traps” Can Make Your Bash Scripts Way More Robust and Reliable

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • Batsh

    A language that compiles to Bash and Windows Batch

  • I wish there was a nicer shell scripting language that simply transpiled to Bash and would generate all this boilerplate code for me. There is https://batsh.org/ which has a nice syntax but it doesn't even support pipes or redirection, making it pretty worthless for shell scripting. I haven't found any other such scripting languages.

  • ShellCheck

    ShellCheck, a static analysis tool for shell scripts

  • >The secret sauce is a pseudo-signal provided by bash, called EXIT, that you can trap; commands or functions trapped on it will execute when the script exits for any reason.

    "Secret Sauce", why is this secret at all.

    Nothing against the author who's helping the ecosystem here, but is there an authoritative guide on Bash that anyone can recommend?

    Hopefully something that's portable between Mac & Linux.

    The web is full of contradictory guides and shellcheck seems to be the last line of defense.

    - https://github.com/koalaman/shellcheck

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • scripting-field-guide

    A booklet on mid-advanced scripting techniques

  • I couldn't find a way to have more than one callback per signal, and created a system to have an array of callbacks:

    https://github.com/kidd/scripting-field-guide/blob/master/bo...

    A nice bonus is that it also keeps the return value of the last non-callback function, so your script behaves better when called from other scripts.

  • Gradle

    Adaptable, fast automation for all

  • "gradle,https://gradle.org"

  • KeenWrite

    Discontinued Free, open-source, cross-platform desktop Markdown text editor with live preview, string interpolation, and math.

  • https://github.com/DaveJarvis/keenwrite/blob/main/scripts/bu...

    My template script provides a way to make user-friendly shell scripts. In a script that uses the template, you define the dependencies and their sources:

        DEPENDENCIES=(

  • warp

    Create self-contained single binary applications (by Reisz)

  • "warp-packer,https://github.com/Reisz/warp/releases"

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts