Skip to content

Instantly share code, notes, and snippets.

@bpgould
Last active October 19, 2022 14:11
Show Gist options
  • Save bpgould/ba731d65f53da1f9d609ce44c3eb4830 to your computer and use it in GitHub Desktop.
Save bpgould/ba731d65f53da1f9d609ce44c3eb4830 to your computer and use it in GitHub Desktop.
Find shell files based on file content, not extension, and run shellcheck for CICD
#!/bin/bash
# finds every file in the directory specified starting with '#!' and ending with 'bash' on the same line
# i.e. #!/bin/bash this allows us to only shellcheck shell files, but this would
# have been a lot simpler if the shell files all had .sh extensions
# added --serverity option due to egregious output in CICD, valid values in order of severity are
# error, warning, info and style. The default is style.
for file in $(find source/legacy -type f -exec awk '/^#!.*bash/{r=1};{exit} END {exit(1-r)}' {} \; -print)
do
shellcheck --severity=warning "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment