mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Add sample to exclude file/directory.
@@ -31,7 +31,7 @@ find /path/to/scripts -type f \( -name '*.sh' -o -name '*.bash' -o -name '*.ksh'
|
|||||||
|
|
||||||
To check files whose shebang indicate that they are sh/bash/ksh scripts:
|
To check files whose shebang indicate that they are sh/bash/ksh scripts:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
# POSIX
|
# POSIX
|
||||||
find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; \
|
find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; \
|
||||||
| xargs shellcheck
|
| xargs shellcheck
|
||||||
@@ -42,3 +42,11 @@ find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {}
|
|||||||
```
|
```
|
||||||
docker run --volume /path/to/scripts:/mnt koalaman/shellcheck-alpine sh -c "find /mnt -name '*.sh' | xargs shellcheck"
|
docker run --volume /path/to/scripts:/mnt koalaman/shellcheck-alpine sh -c "find /mnt -name '*.sh' | xargs shellcheck"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## To exclude file/directory
|
||||||
|
|
||||||
|
To exclude files or directories from the search(`find`) results use `! -path`. To exclude `vendor` directory for example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
find /path/to/scripts -type f \( -name '*.sh' \) ! -path '*/vendor/*' | xargs shellcheck -x -s sh
|
||||||
|
```
|
Reference in New Issue
Block a user