forked from MinaProtocol/mina
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint_rfcs.sh
More file actions
executable file
·40 lines (33 loc) · 744 Bytes
/
Copy pathlint_rfcs.sh
File metadata and controls
executable file
·40 lines (33 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
status=0
rfc_ids=$(ls rfcs/*.md | cut -d/ -f2 | cut -d- -f1 | sort -n)
expected_id=0
error() {
echo "invalid id \"$1\": $2"
status=1
}
fatal_error() {
error "$@"
exit $status
}
for padded_id in $rfc_ids; do
if [ "${#padded_id}" -ne 4 ]; then
error "$padded_id" 'is not 4 characters long'
fi
if [ "$padded_id" -eq 0000 ]; then
id=0
else
id="${padded_id#"${padded_id%%[!0]*}"}"
fi
if [ "$id" -ne "$expected_id" ]; then
if [ "$id" -le "$expected_id" ]; then
error "$padded_id" 'is a duplicate'
else
error "$padded_id" "does not follow expected sequence; expected $expected_id"
expected_id="$id"
fi
else
expected_id=$(($expected_id + 1))
fi
done
exit $status