Created
September 10, 2022 20:57
-
-
Save koonix/e04bc3f66e8cb704bf54456036fae444 to your computer and use it in GitHub Desktop.
check #!/bin/sh-shebanged scripts in /usr/bin for dash-incompatible syntax using shellcheck.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# check #!/bin/sh-shebanged scripts in /usr/bin for | |
# dash-incompatible syntax using shellcheck. | |
# config | |
outdir=~/bashisms | |
searchdir=/usr/bin | |
mkdir -p "$outdir" || exit 1 | |
for file in "$searchdir"/*; do | |
[ -f "$file" ] && [ -r "$file" ] && sed -n '/^#!\/bin\/sh/q0;q1' "$file" || continue | |
shchmsg=$(shellcheck -s dash -i 2039,2169,2240,2279,$(seq -s, 3001 3060) "$file") | |
[ $? -eq 0 ] && continue | |
basename=${file##*/} | |
echo "$basename" | |
printf '%s\n' "$shchmsg" > "$outdir/$basename" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment