@@ -1132,8 +1132,25 @@ jobs:
1132
1132
- uses : actions/checkout@v4
1133
1133
- name : Make sure dictionary words are sorted and unique
1134
1134
run : |
1135
- # `sed` removes the first line (number of words) and
1136
- # the last line (new line).
1135
+ FILE="spellcheck.dic"
1136
+
1137
+ # Verify the first line is an integer.
1138
+ first_line=$(head -n 1 "$FILE")
1139
+ if ! [[ "$first_line" =~ ^[0-9]+$ ]]; then
1140
+ echo "Error: The first line of $FILE must be an integer, but got: '$first_line'"
1141
+ exit 1
1142
+ fi
1143
+ expected_count="$first_line"
1144
+
1145
+ # Check that the number of lines matches the integer.
1146
+ # xargs (with no arguments) will strip leading/trailing whitespacefrom wc's output.
1147
+ actual_count=$(sed '1d' "$FILE" | wc -l | xargs)
1148
+ if [ "$expected_count" -ne "$actual_count" ]; then
1149
+ echo "Error: The number of lines ($actual_count) does not match $expected_count."
1150
+ exit 1
1151
+ fi
1152
+
1153
+ # `sed` removes the first line (number of words).
1137
1154
#
1138
1155
# `sort` makes sure everything in between is sorted
1139
1156
# and contains no duplicates.
@@ -1143,10 +1160,10 @@ jobs:
1143
1160
# environments.
1144
1161
1145
1162
(
1146
- sed '1d; $d' spellcheck.dic | LC_ALL=en_US.UTF8 sort -uc
1163
+ sed '1d' $FILE | LC_ALL=en_US.UTF8 sort -uc
1147
1164
) || {
1148
1165
echo "Dictionary is not in sorted order. Correct order is:"
1149
- LC_ALL=en_US.UTF8 sort -u <(sed '1d; $d' spellcheck.dic )
1166
+ LC_ALL=en_US.UTF8 sort -u <(sed '1d' $FILE )
1150
1167
false
1151
1168
}
1152
1169
- name : Run cargo-spellcheck
0 commit comments