mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +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}
|
shellcheck /path/to/scripts/**.{sh,bash,ksh,bashrc,bash_profile,bash_login,bash_logout}
|
||||||
|
|
||||||
# POSIX
|
# 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 |
|
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' \) \
|
||||||
while IFS="" read -r file
|
| xargs shellcheck
|
||||||
do
|
|
||||||
shellcheck "$file"
|
|
||||||
done
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## By shebang
|
## By shebang
|
||||||
@@ -36,9 +33,5 @@ To check files whose shebang indicate that they are sh/bash/ksh scripts:
|
|||||||
|
|
||||||
```
|
```
|
||||||
# POSIX
|
# POSIX
|
||||||
find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
|
find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; | xargs shellcheck
|
||||||
while IFS="" read -r file
|
|
||||||
do
|
|
||||||
shellcheck "$file"
|
|
||||||
done
|
|
||||||
```
|
```
|
Reference in New Issue
Block a user