Skip to content

Commit

Permalink
Fixes issues with globbing files with partial match(#23)
Browse files Browse the repository at this point in the history
Co-authored-by: Joakim Sørensen <[email protected]>
  • Loading branch information
pvogt09 and ludeeus authored Jul 28, 2020
1 parent c7d4e49 commit 73cbb64
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
41 changes: 23 additions & 18 deletions runaction
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare -a excludes
declare -a tmp

statuscode=0
shebangregex="^#! */[^ ]*/(env *)?[abkz]*sh"

excludes+=( ! -path *./.git/* )
excludes+=( ! -path *.go )
Expand All @@ -25,34 +26,38 @@ readarray -d '' filepaths < <(find . -type f "${excludes[@]}" \
'(' \
\
-name '*.bash' \
-o -path '*/.bash*' \
-o -path '*/bash*' \
-o -name '.bashrc' \
-o -name 'bashrc' \
-o -name '.bash_aliases' \
-o -name '.bash_completion' \
-o -name '.bash_login' \
-o -name '.bash_logout' \
-o -name '.bash_profile' \
-o -name 'bash_profile' \
-o -name '*.ksh' \
-o -name 'ksh*' \
-o -path '*/.ksh*' \
-o -path '*/ksh*' \
-o -name 'suid_profile' \
-o -name '*.zsh' \
-o -name '.zlogin*' \
-o -name 'zlogin*' \
-o -name '.zlogout*' \
-o -name 'zlogout*' \
-o -name '.zprofile*' \
-o -name 'zprofile*' \
-o -path '*/.zsh*' \
-o -path '*/zsh*' \
-o -name '.zlogin' \
-o -name 'zlogin' \
-o -name '.zlogout' \
-o -name 'zlogout' \
-o -name '.zprofile' \
-o -name 'zprofile' \
-o -name '.zsenv' \
-o -name 'zsenv' \
-o -name '.zshrc' \
-o -name 'zshrc' \
-o -name '*.sh' \
-o -path '*/.profile*' \
-o -path '*/.shlib*' \
-o -path '*/shlib*' \
-o -path '*/.profile' \
-o -path '*/profile' \
-o -name '*.shlib' \
')'\
\
-print0)


readarray -d '' tmp < <(find . "${excludes[@]}" -type f ! -name '*.*' -perm /111 -print0)
for file in "${tmp[@]}"; do
head -n1 "$file" | grep -Eqs "^#! */[^ ]*/(env *)?[abkz]*sh" || continue
head -n1 "$file" | grep -Eqs "$shebangregex" || continue
filepaths+=("$file")
done

Expand Down
6 changes: 6 additions & 0 deletions testfiles/bashfile.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* C code test file
* file that should not be matched for shellcheck runs
*/
int main(void) {
return 0;
}

0 comments on commit 73cbb64

Please sign in to comment.