Skip to content

Commit 530948d

Browse files
committed
Have check-mode.sh handle errors better on macOS
In bash 3.2, which is used on macOS, `[[` commands don't invoke `set -e` behavior. This adds an explicit check. This also improves some code that sliced an array instead of using the variables its elements were already assigned to. One of them is used twice, and indexing in the existing usage would make the meaning less clear. So the variables would not be reasonable to eliminate by slicing the array, without other refactoring.
1 parent a9b3b48 commit 530948d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

etc/check-mode.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ readonly record_pattern='^([0-7]+) ([[:xdigit:]]+) [[:digit:]]+'$'\t''(.+)$'
3232

3333
# Check regular files named with a `.sh` suffix.
3434
while IFS= read -rd '' record; do
35-
[[ $record =~ $record_pattern ]]
35+
[[ $record =~ $record_pattern ]] || exit 2 # bash 3.2 `set -e` doesn't cover this.
3636
mode="${BASH_REMATCH[1]}"
3737
oid="${BASH_REMATCH[2]}"
3838
path="${BASH_REMATCH[3]}"
3939

4040
case "$mode" in
4141
100644 | 100755)
42-
check_item "${BASH_REMATCH[@]:1:3}"
42+
check_item "$mode" "$oid" "$path"
4343
;;
4444
esac
4545
done < <(git ls-files -sz -- '*.sh')

0 commit comments

Comments
 (0)