Skip to content

Instantly share code, notes, and snippets.

@grahamc
Last active July 31, 2018 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamc/56597a108f56114e80055345f07c234b to your computer and use it in GitHub Desktop.
Save grahamc/56597a108f56114e80055345f07c234b to your computer and use it in GitHub Desktop.
shellcheckHook = makeSetupHook {
name = "shellcheck-hook";
substitutions = {};
}
(pkgs.writeText "foo" ''
(
# lol
filename=$(cat "$0" | tail -n1 | ${pkgs.utillinux}/bin/rev | cut -d' ' -f2 | ${pkgs.utillinux}/bin/rev)
${pkgs.shellcheck}/bin/shellcheck -s bash "$filename"
)
'');
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p shellcheckHook -I nixpkgs=./
foo=$1
echo $foo
echo $((1 + 1)))
@grahamc
Copy link
Author

grahamc commented Jul 31, 2018

grahamc@Morbo> ./test.sh 

In ./test.sh line 1:
#!/usr/bin/env nix-shell
^-- SC1008: This shebang was unrecognized. Note that ShellCheck only handles sh/bash/dash/ksh.


In ./test.sh line 5:
echo $foo
     ^-- SC2086: Double quote to prevent globbing and word splitting.


In ./test.sh line 6:
echo $((1 + 1)))
               ^-- SC1089: Parsing stopped here. Is this keyword correctly matched up?


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment