Fix macOS incompatibility in format.sh (#9832)

Co-authored-by: Mehrdad <noreply@github.com>
This commit is contained in:
mehrdadn
2020-07-31 09:25:55 -07:00
committed by GitHub
co-authored by Mehrdad
parent 006e034cdb
commit 78995d085f
+6 -6
View File
@@ -199,12 +199,12 @@ format_changed() {
shellcheck_bazel
fi
local shell_files
# shellcheck disable=SC2207
shell_files=($(
git diff --name-only --diff-filter=ACRM "$MERGEBASE" -- '*.sh' &&
git diff --name-only --diff-filter=ACRM "$MERGEBASE" -- ':(exclude)*.*' | xargs -r git --no-pager grep -l '^#!\(/usr\)\?/bin/\(env \+\)\?\(ba\)\?sh'
))
local shell_files non_shell_files
non_shell_files=($(git diff --name-only --diff-filter=ACRM "$MERGEBASE" -- ':(exclude)*.sh'))
shell_files=($(git diff --name-only --diff-filter=ACRM "$MERGEBASE" -- '*.sh'))
if [ 0 -lt "${#non_shell_files[@]}" ]; then
shell_files+=($(git --no-pager grep -l -- '^#!\(/usr\)\?/bin/\(env \+\)\?\(ba\)\?sh' "${non_shell_files[@]}"))
fi
if [ 0 -lt "${#shell_files[@]}" ]; then
shellcheck_scripts "${shell_files[@]}"
fi