markdown-shellcheck
This AKW script extracts shell code blocks from Markdown files and runs shellcheck on them.
Only fenced code blocks where the info string starts with bash
, ksh
, zsh
, or sh
are extracted.
The &|
and ENDFILE
GNU AWK extensions are used.
If you don't like that, remove the ENDFILE
block and replace &|
with temporary files.
Example usage
$ ./markdown-shellcheck.awk file1.md file2.md
In file1.md line 126:
if [ $1 == b ]; then
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
^-- SC3014 (warning): In POSIX sh, == in place of = is undefined.
Did you mean:
if [ "$1" = b ]; then
In file2.md line 62:
xdotool windowunmap $(xdotool getactivewindow)
^------------------------^ SC2046 (warning): Quote this to prevent word splitting.
Installation
Copy markdown-shellcheck.awk into a directory inside your $PATH
.
License
MIT