Ask HN: Let's Build CheckStyle for Bash?

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

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • Bash-Checkstyle

    CI tool to verify some degree of Google Style Guide for Bash compliance.

  • Hence, I thought we could make a Bash linting tool that verifies compliance with the Shell Style Guide by Google. To do so, a brief start was made here: https://github.com/TruCol/checkstyle-for-bash It identifies/lists elements in that style guide that may be verified automatically. Since Bash has been around longer than me, I think there may be some people better suited for the development of this enhanced linter. Hence, I thought it might be wise, for impact and usability, to share this idea here.

    What do you say, HN?

    [0]: https://google.github.io/styleguide/shellguide.html

  • shfmt

    Dockernized shfmt. This formats shell script. (by tmknom)

  • - sh: https://github.com/mvdan/sh

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • ShellCheck

    ShellCheck, a static analysis tool for shell scripts

  • After working with Bash and Shellcheck for a few months, I noticed I could improve my code quality by making it compliant with the Shell Style Guide by Google[0]. While working on that, I thought some aspects of this Shell style guide can be verified automatically, granted some assumptions/opinions are formed. So I looked around for linting tools and autoformatters for Bash:

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

  • ale

    Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support

  • From Asynchronous Lint Engine (ALE): https://github.com/dense-analysis/ale/blob/master/supported-tools.md

  • bashate

    Code style enforcement for bash programs. Mirror of code maintained at opendev.org.

  • cspell

    A Spell Checker for Code!

  • - cspell: https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell

  • bash-language-server

    A language server for Bash

  • - Bash Language Server: https://github.com/bash-lsp/bash-language-server

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

    Discontinued A shell linting utility.

  • - shlint: https://github.com/duggan/shlint (archived)

  • docker-flask-example

    A production ready example Flask app that's using Docker and Docker Compose.

  • Every web application I work with has this idea of a "run" script, basically a self isolated shell script to help automate running certain commands. Sort of like a Makefile except with the full power of your shell.

    For example: https://github.com/nickjj/docker-flask-example/blob/main/run

    In a bigger project this file tends to grow quite large, even when you have the power of a programming language available to you there's plenty of tasks where it makes sense to keep it as a shell script.

    The run script for my infrastructure repo at one place I work for is almost 1,500 lines shell scripting. It's not a big jumbled mess either, it's very organized and optimized to make running long commands faster and less error prone (even if they happen to be called in CI).

  • murex

    A smarter shell and scripting environment with advanced features designed for usability, safety and productivity (eg smarter DevOps tooling)

  • If it is for myself: murex (my own DevOps focused shell: https://murex.rocks)

    If it is for work: either Bash or whatever that companies preferred software development language (over the last ~20 years that's included: Pascal, Visual Basic, PL/SQL, Perl, PHP, Python, Typescript and others I've likely forgotten. Different companies will have different preferences)

    If performance matters then these days Go is my "goto" language because it's a good compromise in terms of developer productivity and application performance. But I've used Java, C and C++ too. Depending on the particular problem I'm trying to solve.

    ...and if you ask me again in 5 years then the answer will be completely different again.

    The sort answer is: there's no such thing as a single answer. Everyone will have their own preferences and business requirements.

  • hck

    A sharp cut(1) clone.

  • You might want to check out 'hck' to replace 'cut'.

    https://github.com/sstadick/hck

  • rustup.rs

    The Rust toolchain installer (by hsivonen)

  • Much of the time that people are writing shell scripts, they're writing them not because they prefer shell syntax to that of some other language, but rather because they're creating a script that needs to be widely disseminated/deployed to all sorts of machines with unpredictable install bases.

    This is why a large fraction of the shell scripts that exist in the world still hold to Bourne shell syntax, rather than using any of the syntax extensions from its descendant shells — Bourne shell (or at least, something at /bin/sh that interprets Bourne-shell syntax) is part of the POSIX standard. So you can expect any POSIX system — no matter how weird — to be able to run (Bourne) shell scripts. You can run them on Alpine. You can run them on Busybox. You can run them on your NAS. You can run them on your router. You can run them in your initramfs, on your Kubernetes nodes, on your Mosix nodes, whatever.

    For an example of the type of script I'm talking about — see e.g. the script you download+run when you run the command-line on https://rustup.rs: https://github.com/hsivonen/rustup.rs/blob/master/rustup-ini...

    There's absolutely no benefit that this script gets from being written directly in POSIX-compiliant Bourne shell syntax, rather than being written in something that compiles to it; any more than programs for your PC would benefit from being written directly in ASM rather than in something that compiles to it.

  • bish

    Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.

  • Oh people have tried - here are a few https://stackoverflow.com/questions/10239235/are-there-any-l...

    I vaguely remember quite liking bish when I saw it years ago https://github.com/tdenniston/bish but it looks like no commits in 6 years.

    This shelljs thing looks more promising, but really tedious to use https://github.com/shelljs/shelljs - shell.rm('-rf', 'out/Release'); I'd rather suffer proper bash than have to do that sort of thing.

    Nothing seems to have really caught on so far. Bash is easy to learn and hack on, and before you know it, that simple install.sh that started out moving a few files around is 5000 lines, unmaintainable, and critical to bootstrapping your software :)

  • shelljs

    :shell: Portable Unix shell commands for Node.js

  • Oh people have tried - here are a few https://stackoverflow.com/questions/10239235/are-there-any-l...

    I vaguely remember quite liking bish when I saw it years ago https://github.com/tdenniston/bish but it looks like no commits in 6 years.

    This shelljs thing looks more promising, but really tedious to use https://github.com/shelljs/shelljs - shell.rm('-rf', 'out/Release'); I'd rather suffer proper bash than have to do that sort of thing.

    Nothing seems to have really caught on so far. Bash is easy to learn and hack on, and before you know it, that simple install.sh that started out moving a few files around is 5000 lines, unmaintainable, and critical to bootstrapping your software :)

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