From 78995d085f8b4581b4320ff6199023b554dd1f75 Mon Sep 17 00:00:00 2001 From: mehrdadn Date: Fri, 31 Jul 2020 09:25:55 -0700 Subject: [PATCH] Fix macOS incompatibility in format.sh (#9832) Co-authored-by: Mehrdad --- ci/travis/format.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/travis/format.sh b/ci/travis/format.sh index ca0530a9c..e6fa6c058 100755 --- a/ci/travis/format.sh +++ b/ci/travis/format.sh @@ -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