ShellCheck VS sh

Compare ShellCheck vs sh and see what are their differences.

ShellCheck

ShellCheck, a static analysis tool for shell scripts (by koalaman)

sh

A shell parser, formatter, and interpreter with bash support; includes shfmt (by mvdan)
Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • ONLYOFFICE ONLYOFFICE Docs — document collaboration in your environment
  • SonarLint - Clean code begins in your IDE with SonarLint
ShellCheck sh
457 19
32,226 5,891
- -
7.5 7.6
6 days ago 3 days ago
Haskell Go
GNU General Public License v3.0 only BSD 3-clause "New" or "Revised" License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

ShellCheck

Posts with mentions or reviews of ShellCheck. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-05-21.

sh

Posts with mentions or reviews of sh. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-02-11.
  • Shfmt – format shell programs (like gofmt, rustfmt)
    4 projects | news.ycombinator.com | 11 Feb 2023
    For the first two caveats, I actually agree that we could and should handle ambiguous input. It just hasn't been a priority because doing that properly would be quite a bit of work, and such ambiguous syntax isn't particularly common. See https://github.com/mvdan/sh/issues/686 for my current thoughts on how to tackle it.

    The third caveat concerns parsing `export` and `let` as keywords rather than as builtins. Like the README says, this is to properly build the syntax without leaving opaque strings as expressions, but also to support `declare foo=(bar)` which wouldn't work if `declare` was treated like any other builtin simple command.

    How else would you have a static parser handle these two builtins? They are in a bit of an awkward middle ground between builtin and keyword. My instinct is that giving them special treatment in the parser to allow tokens like `(`, while at the same time representing them in the syntax tree with opaque strings as expressions, would be pretty underwhelming to any users of the parser.

    That said, we already have that problem with `let "foo=123"` for example, where our parser currently represents the expression as the quoted string without going any deeper. https://github.com/mvdan/sh/issues/754#issuecomment-96329574... considers doing a second parse stage in the shell interpreter to fix cases like these, though always doing a second parse could get expensive.

    We _could_ leave all arithmetic expressions as input strings in the parser, and do all the actual parsing when they are evaluated. That would be more compatible with Bash and more consistent. But it would also be less useful to any parser users who don't run into any of these weird edge cases, which aren't common at all, I think.

    In short, I have some ideas, but I'm not sure at all what's best :) Doing a good job for 99% of users feels better than aiming for 100% compatibility with bash syntax, particularly where bash syntax is a bit weird.

    4 projects | news.ycombinator.com | 11 Feb 2023
  • Gofumpt: It's like gofmt except more strict
    4 projects | news.ycombinator.com | 10 Feb 2023
    My bad, I completely screwed this up... the as of yet undiscussed project is:

    https://github.com/mvdan/sh

    (not shmfmt)

  • Gosh Linux shell written in Golang
    2 projects | reddit.com/r/golang | 23 Jan 2023
    I support projects like this for purposes of exploration and practice. But don't expect people to use it when there are already well established projects out there like: https://github.com/mvdan/sh
  • similar to shellcheck?
    5 projects | reddit.com/r/bash | 21 Apr 2022
    There are also: - shfmt - sh - bash language server - bashate
  • Code formatter, linters, etc. Recommendations?
    4 projects | reddit.com/r/bash | 29 Sep 2021
    There is shellcheck, and shellharden which is a strict version of it. There are similar stuff here, some that also help with your editor. You can also use a docker version of shfmt. See here for a quick tutorial on shfmt.
  • First Bash Script
    2 projects | reddit.com/r/bash | 23 Sep 2021
    Now go ahead and install shellcheck and shfmt to get even better at it.
  • How can I fix this install script to detect archives, and what are the strange numbers for the permissions? Plz help me understand.
    5 projects | reddit.com/r/bash | 6 Jul 2021
    INSTALL_DIR=/usr/local/bin # Call with arguments (location,filename,sha,name,strip) function download_verify_install() { curl -LOf "${1}${2}" echo "${3} ./${2}" | sha512sum --check tar -C $INSTALL_DIR/ -xf "${2}" --no-anchored "${4}" --strip="${5}" } install_redhat_binaries() { BOLD=$(tput bold) RESET=$(tput sgr0) set -euo pipefail local PANDOC_LOCATION=https://github.com/jgm/pandoc/releases/download/2.11.2/ local PANDOC_FILENAME=pandoc-2.11.2-linux-amd64.tar.gz local PANDOC_SHA=9d265941f224d376514e18fc45d5292e9c2481b04693c96917a0d55ed817b190cf2ea2666097388bfdf30023db2628567ea04ff6b9cc3316130a8190da72c605 local SHELLCHECK_LOCATION=https://github.com/koalaman/shellcheck/releases/download/v0.7.2/ local SHELLCHECK_FILENAME=shellcheck-v0.7.2.linux.x86_64.tar.xz local SHELLCHECK_SHA=067e2b8ee1910218de1e62068f7cc86ed7048e97b2a9d7c475ea29ae81c17a944376ce5c240d5c783ef3251d9bee7d7d010351958314eadd0fc88b5decfd8328 local SHFMT_LOCATION=https://github.com/mvdan/sh/releases/download/v3.2.2/ local SHFMT_FILENAME=shfmt_v3.2.2_linux_amd64 local SHFMT_SHA=d4e699575899f7c44dbce54f6414fb63c0527e7d743ea724cb0091417e07a353c1d156d4184580a260ca855cdf5e01cdf46b353f04cf5093eba3ffc02223f1c6 local BAT_LOCATION=https://github.com/sharkdp/bat/releases/download/v0.18.1/ local BAT_FILENAME=bat-v0.18.1-x86_64-unknown-linux-gnu.tar.gz local BAT_SHA=5ccab17461d2c707dab2e917daacdabe744c8f8c1e09330c03f17b6f9a9be3d79d8a2786c5e37b1bdbdb981e9d9debfec909b4a99bf62329d6f12c1c3e8dfcb7 local RIPGREP_LOCATION=https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ local RIPGREP_FILENAME=ripgrep-13.0.0-x86_64-unknown-linux-musl.tar.gz local RIPGREP_SHA=cdc18bd31019fc7b8509224c2f52b230be33dee36deea2e4db1ee8c78ace406c7cd182814d056f4ce65ee533290a674822432777b61c2b4bc8cc4a4ea107cfde echo -e "${BOLD}Installing binaries for RHEL clones not available in repositories...${RESET}\n" download_verify_install "$PANDOC_LOCATION" "$PANDOC_FILENAME" "$PANDOC_SHA" "pandoc" 2 download_verify_install "$SHELLCHECK_LOCATION" "$SHELLCHECK_FILENAME" "$SHELLCHECK_SHA" "shellcheck" 1 download_verify_install "$BAT_LOCATION" "$BAT_FILENAME" "$BAT_SHA" "bat" 1 download_verify_install "$RIPGREP_LOCATION" "$RIPGREP_FILENAME" "$RIPGREP_SHA" "rg" 1 # download_verify "$SHFMT_LOCATION" "$SHFMT_FILENAME" "$SHFMT_SHA" # chmod +x $SHFMT_FILENAME # mv $SHFMT_FILENAME $INSTALL_DIR/shfmt } install_redhat_binaries
  • Config to edit bash scripts with fancy LSP features, linting and formatting
    7 projects | reddit.com/r/vim | 17 Jun 2021
    Does anybody have such? Maybe you could share your experience? I use coc.nvim. My eyes fell on these 3 tools. The first one is language server and it has coc extensions coc-sh. But others are not so I am not sure which vim plugin should I use to hook them up: besides diagnostic-languageserver there are syntastic and neomake - bash-language-server - shellcheck - shfmt
  • How to get diagnostics in BASH scripts (.sh files) with Native LSP?
    4 projects | reddit.com/r/neovim | 17 May 2021
    I also use shfmt with efm-langserver too. Shfmt provides auto-formatting. For completions I use bash-language-server with native lsp.

What are some alternatives?

When comparing ShellCheck and sh you can also consider the following projects:

bash-language-server - A language server for Bash

shfmt - Dockernized shfmt. This formats shell script.

PowerShell - PowerShell for every system!

shellharden - The corrective bash syntax highlighter

efm-langserver - General purpose Language Server

neomake - Asynchronous linting and make framework for Neovim/Vim

bat - A cat(1) clone with wings.

stan - 🕵️ Haskell STatic ANalyser

hdocs - Haskell docs tool

maam - A monadic approach to static analysis following the methodology of AAM

proot - An chroot-like implementation using ptrace.

shfmt - A shell formatter (sh/bash/mksh)