mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Fix quoting of find
command and use xargs instead of a while loop, which preserves the exit status.
@@ -23,11 +23,8 @@ shopt -s nullglob dotglob
|
||||
shellcheck /path/to/scripts/**.{sh,bash,ksh,bashrc,bash_profile,bash_login,bash_logout}
|
||||
|
||||
# POSIX
|
||||
find /path/to/scripts -type f \( -name "*.sh" -o -name "*.bash" -o -name "*.ksh" -o -name "*.bashrc" -o -name "*.bash_profile" -o -name "*.bash_login" -o -name "*.bash_logout" \) -print |
|
||||
while IFS="" read -r file
|
||||
do
|
||||
shellcheck "$file"
|
||||
done
|
||||
find /path/to/scripts -type f \( -name '*.sh' -o -name '*.bash' -o -name '*.ksh' -o -name '*.bashrc' -o -name '*.bash_profile' -o -name '*.bash_login' -o -name '*.bash_logout' \) \
|
||||
| xargs shellcheck
|
||||
```
|
||||
|
||||
## By shebang
|
||||
@@ -36,9 +33,5 @@ To check files whose shebang indicate that they are sh/bash/ksh scripts:
|
||||
|
||||
```
|
||||
# POSIX
|
||||
find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
|
||||
while IFS="" read -r file
|
||||
do
|
||||
shellcheck "$file"
|
||||
done
|
||||
find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; | xargs shellcheck
|
||||
```
|
Reference in New Issue
Block a user