From 40fc3765968654ad5315277f61a25b8e6364f034 Mon Sep 17 00:00:00 2001 From: Michael Diamond Date: Mon, 20 Jan 2020 23:03:11 -0800 Subject: [PATCH] Fix quoting of `find` command and use xargs instead of a while loop, which preserves the exit status. --- Recursiveness.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Recursiveness.md b/Recursiveness.md index 030110c..7dee90c 100644 --- a/Recursiveness.md +++ b/Recursiveness.md @@ -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 ``` \ No newline at end of file