Skip to content

Commit

Permalink
Let shellcheck handle good vs bad shell types
Browse files Browse the repository at this point in the history
This matches official shellcheck pre-commit hook at [1]. This works because
shellcheck will silently skip "badShells" so there isn't a good reason to
do this here. The old setup was actually causing pre-commit to skip shell
scripts ending with .sh since both types *and* types_or were specified but
the identified tags resulted in an empty set:

$ cat t.sh

echo hi
$ nix-shell -p python3Packages.identify --run 'identify-cli t.sh'
["file", "non-executable", "shell", "text"]

An argument could be had that 'sh' should have shown up due to the extension similar to other shells but I still believe we should merge this and match upstream.

1: https://github.com/koalaman/shellcheck-precommit/blob/v0.9.0/.pre-commit-hooks.yaml#L7
  • Loading branch information
mmlb committed Aug 15, 2023
1 parent c5ac3aa commit 61bda56
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1055,16 +1055,6 @@ in
name = "shellcheck";
description = "Format shell files.";
types = [ "shell" ];
types_or =
# based on `goodShells` in https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Parser.hs
[
"sh"
"ash"
"bash"
"bats"
"dash"
"ksh"
];
entry = "${tools.shellcheck}/bin/shellcheck";
};
bats =
Expand Down

0 comments on commit 61bda56

Please sign in to comment.