Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions etc/check-mode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd -- "$root"
symbolic_shebang="$(printf '#!' | od -An -ta)"
status=0

function check () {
function check_item () {
local mode="$1" oid="$2" path="$3" symbolic_magic

# Extract the first two bytes (or less if shorter) and put in symbolic form.
Expand All @@ -28,11 +28,18 @@ function check () {
status=1
}

readonly record_pattern='^([0-7]+) ([[:xdigit:]]+) [[:digit:]]+'$'\t''(.+)$'

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

case "$mode" in
100644 | 100755)
check "$mode" "$oid" "$path"
check_item "$mode" "$oid" "$path"
;;
esac
done < <(git ls-files -sz -- '*.sh')
Expand Down
Loading