How to do things safely in Bash

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
  • ShellCheck

    ShellCheck, a static analysis tool for shell scripts

  • If you’re interested in writing safe shell scripts then check out shellcheck:

    https://github.com/koalaman/shellcheck

    If you’re interested I’ve written a git hook for it that runs a check when you git commit:

    https://github.com/alblue/scripts/blob/main/shellcheck-pre-c...

    You should also check out her Google shell script style guide:

    https://google.github.io/styleguide/shellguide.html

  • shellharden

    The corrective bash syntax highlighter

  • 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
  • scripts

    Useful scripts that I find handy to work with (by alblue)

  • If you’re interested in writing safe shell scripts then check out shellcheck:

    https://github.com/koalaman/shellcheck

    If you’re interested I’ve written a git hook for it that runs a check when you git commit:

    https://github.com/alblue/scripts/blob/main/shellcheck-pre-c...

    You should also check out her Google shell script style guide:

    https://google.github.io/styleguide/shellguide.html

  • rust_cmd_lib

    Common rust command-line macros and utilities, to write shell-script like tasks in a clean, natural and rusty way

  • zsh is also doing the variable substitution better than bash. FYI, I just released rust_cmd_lib 1.0 recently, which can do variable substitution without any quotes: https://github.com/rust-shell-script/rust_cmd_lib

  • makesure

    Simple task/command runner with declarative goals and dependencies

  • 5. Easy shell interoperability

    As an example here is a simplistic build tool [1] I’ve developed in AWK. As you can check [2] it runs unchanged under Linux/macOS/Win (via Git Bash).

    [1] https://github.com/xonixx/makesure/blob/main/makesure.awk

  • oil

    Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!

  • Have you tried any of the shells here?

    https://github.com/oilshell/oil/wiki/Alternative-Shells

    Discussed recently: https://news.ycombinator.com/item?id=26121592

    A lot of them are "fundamentally reimagining" shell (actually I would say most of them are; whether that's good or bad depends on the user's POV).

    Oil is reimagining shell, but also providing a graceful upgrade path. Out of all the shells I'd say it's most focused on the fundamental language and runtime, and less on the interactive issues (right now).

  • babashka

    Native, fast starting Clojure interpreter for scripting

  • Actually, the one thing that I as a systems engineer really like about Clojure is the threading macro (-> some-data some-function-applied-on-some-data some-otherfunction) or (->> ...) for inserting not as a second, but last argument. That is like a pipeline but usually more readable to me even though I am proficient with the shell (and I must admit even PowerShell, which really is more comparable to Perl with a bit of SQL and other flavours here and there than bash).

    Sysadmins/ system engineers might love Babashka: https://github.com/babashka/babashka which is a large subset of Clojure + some frequently used libraries as a native GraalVM image. It is portable, has very fast startup and if the script becomes a larger program, you can easily switch to ClojureScript + Node.js (e.g. for still very fast startup) or Clojure (on the normal JVM) or perhaps build your own GraalVM image. You might also just open a REPL and run it as a single session but that is rather unique in the sysadmin/ systems engineer space, where most things are launched on schedule e.g. each 5 minutes by a script and in case the startup time is somewhat long, it might dominate the execution time.

    Btw. babashka seems to be about twice as fast to start on my Debian:

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • PowerShell

    PowerShell for every system!

  • I'd probably like to see powershell usage increase too, but I think we may be in the minority. Every time it comes up I check to see if it is available in Debian and see that the packaging bug¹ has been open for years without anyone caring enough to move on it. The referenced upstream bug² points out that it isn't capital-F Free enough to distribute [yet], but you'd expect more comments in the bug if people were pushing(or a package for the non-free section).

    ¹ https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834756

    ² https://github.com/PowerShell/PowerShell/issues/5869

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