Skip to content

Commit ec7c94b

Browse files
sideshowbarkerdomenic
authored andcommitted
Fix stuff caught by https://www.shellcheck.net/
1 parent 1feb9dd commit ec7c94b

File tree

2 files changed

+130
-91
lines changed

2 files changed

+130
-91
lines changed

build.sh

+122-83
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ for arg in "$@"
2727
do
2828
case $arg in
2929
-c|--clean)
30-
rm -rf $HTML_CACHE
30+
rm -rf "$HTML_CACHE"
3131
exit 0
3232
;;
3333
-h|--help)
@@ -66,11 +66,16 @@ done
6666

6767
# $SKIP_BUILD_UPDATE_CHECK is set inside the Dockerfile so that we don't check for updates both inside and outside
6868
# the Docker container.
69-
if [ "$DO_UPDATE" == true -a "$SKIP_BUILD_UPDATE_CHECK" != true ]; then
69+
if [[ "$DO_UPDATE" == true && "$SKIP_BUILD_UPDATE_CHECK" != true ]]; then
7070
$QUIET || echo "Checking if html-build is up to date..."
71+
GIT_FETCH_ARGS=()
72+
if ! $VERBOSE ; then
73+
GIT_FETCH_ARGS+=( --quiet )
74+
fi
7175
# TODO: `git remote get-url origin` is nicer, but new in Git 2.7.
7276
ORIGIN_URL=$(git config --get remote.origin.url)
73-
git fetch $($VERBOSE || echo "-q") $ORIGIN_URL master
77+
GIT_FETCH_ARGS+=( "$ORIGIN_URL" master)
78+
git fetch "${GIT_FETCH_ARGS[@]}"
7479
NEW_COMMITS=$(git rev-list --count HEAD..FETCH_HEAD)
7580
if [ "$NEW_COMMITS" != "0" ]; then
7681
$QUIET || echo
@@ -98,9 +103,9 @@ echo "3) Create a clone from an existing fork, by GitHub username."
98103
echo "4) Create a clone from an existing fork, by custom URL."
99104
echo "5) Quit"
100105
echo
101-
read -e -p "Choose 1-5: " choice
106+
read -r -e -p "Choose 1-5: " choice
102107
if [ "1" = "$choice" ]; then
103-
read -e -p "Path to your existing clone: "
108+
read -r -e -p "Path to your existing clone: "
104109
HTML_SOURCE=$(echo "$REPLY" | xargs) # trims leading/trailing space
105110
if [[ "$HTML_SOURCE" = "" ]]; then
106111
chooseRepo
@@ -111,15 +116,15 @@ elif [ "2" = "$choice" ]; then
111116
confirmRepo
112117
elif [ "3" = "$choice" ]; then
113118
echo
114-
read -e -p "GitHub username of fork owner: "
119+
read -r -e -p "GitHub username of fork owner: "
115120
GH_USERNAME=$(echo "$REPLY" | xargs) # trims leading/trailing space
116121
if [ -z "$GH_USERNAME" ]; then
117122
chooseRepo
118123
fi
119124
echo
120125
echo "Does a fork already exist at https://github.com/$GH_USERNAME/html?"
121126
echo
122-
read -e -p "Y or N? " yn
127+
read -r -e -p "Y or N? " yn
123128
if [[ "y" = "$yn" || "Y" = "$yn" ]]; then
124129
HTML_REPO="https://github.com/$GH_USERNAME/html.git"
125130
confirmRepo
@@ -130,7 +135,7 @@ elif [ "3" = "$choice" ]; then
130135
fi
131136
elif [ "4" = "$choice" ]; then
132137
echo
133-
read -e -p "URL: "
138+
read -r -e -p "URL: "
134139
REPLY=$(echo "$REPLY" | xargs) # trims leading/trailing space
135140
if [ -z "$REPLY" ]; then
136141
chooseRepo
@@ -152,7 +157,7 @@ function confirmRepo {
152157
echo
153158
echo "OK, build from the $HTML_SOURCE/source file?"
154159
echo
155-
read -e -p "Y or N? " yn
160+
read -r -e -p "Y or N? " yn
156161
if [[ "y" = "$yn" || "Y" = "$yn" ]]; then
157162
return
158163
else
@@ -171,11 +176,16 @@ function confirmRepo {
171176
echo
172177
echo "OK, clone from $HTML_REPO?"
173178
echo
174-
read -e -p "Y or N? " yn
179+
read -r -e -p "Y or N? " yn
180+
GIT_CLONE_ARGS=( "$HTML_GIT_CLONE_OPTIONS" )
181+
if $VERBOSE; then
182+
GIT_CLONE_ARGS+=( --verbose )
183+
elif $QUIET; then
184+
GIT_CLONE_ARGS+=( --quiet )
185+
fi
186+
GIT_CLONE_ARGS+=( "$HTML_REPO" "$HTML_SOURCE" )
175187
if [[ "y" = "$yn" || "Y" = "$yn" ]]; then
176-
git clone $HTML_GIT_CLONE_OPTIONS \
177-
$($VERBOSE && echo "--verbose" || $QUIET && echo "--quiet") \
178-
$HTML_REPO $HTML_SOURCE
188+
git clone "${GIT_CLONE_ARGS[@]}"
179189
else
180190
unset HTML_SOURCE
181191
chooseRepo
@@ -184,12 +194,12 @@ function confirmRepo {
184194

185195
$QUIET || echo "Looking for the HTML source (set HTML_SOURCE to override)..."
186196
if [ -z "$HTML_SOURCE" ]; then
187-
PARENT_DIR=$(dirname $DIR)
188-
if [ -f $PARENT_DIR/html/source ]; then
197+
PARENT_DIR=$(dirname "$DIR")
198+
if [ -f "$PARENT_DIR/html/source" ]; then
189199
HTML_SOURCE=$PARENT_DIR/html
190200
$QUIET || echo "Found $HTML_SOURCE (alongside html-build)..."
191201
else
192-
if [ -f $DIR/html/source ]; then
202+
if [ -f "$DIR/html/source" ]; then
193203
HTML_SOURCE=$DIR/html
194204
$QUIET || echo "Found $HTML_SOURCE (inside html-build)..."
195205
else
@@ -221,7 +231,7 @@ function relativePath {
221231
while [[ "${target#$commonPart}" == "${target}" ]]; do
222232
# no match, means that candidate common part is not correct
223233
# go up one level (reduce common part)
224-
commonPart="$(dirname $commonPart)"
234+
commonPart=$(dirname "$commonPart")
225235
# and record that we went back, with correct / handling
226236
if [[ -z $result ]]; then
227237
result=".."
@@ -247,7 +257,7 @@ function relativePath {
247257
result="${forwardPart:1}"
248258
fi
249259

250-
echo $result
260+
echo "$result"
251261
}
252262

253263
if [ "$USE_DOCKER" == true ]; then
@@ -257,7 +267,7 @@ if [ "$USE_DOCKER" == true ]; then
257267
fi
258268

259269
# $SOURCE_RELATIVE helps on Windows with Git Bash, where /c/... is a symlink, which Docker doesn't like.
260-
SOURCE_RELATIVE=$(relativePath $(pwd) $HTML_SOURCE)
270+
SOURCE_RELATIVE=$(relativePath "$(pwd)" "$HTML_SOURCE")
261271

262272
VERBOSE_OR_QUIET_FLAG=""
263273
$QUIET && VERBOSE_OR_QUIET_FLAG+="--quiet"
@@ -266,64 +276,78 @@ if [ "$USE_DOCKER" == true ]; then
266276
NO_UPDATE_FLAG="--no-update"
267277
$DO_UPDATE && NO_UPDATE_FLAG=""
268278

269-
docker build --tag whatwg-html \
270-
--build-arg html_source_dir=$SOURCE_RELATIVE \
271-
--build-arg verbose_or_quiet_flag=$VERBOSE_OR_QUIET_FLAG \
272-
--build-arg no_update_flag=$NO_UPDATE_FLAG \
273-
$($QUIET && echo "--quiet") .
279+
DOCKER_ARGS=( --tag whatwg-html \
280+
--build-arg "html_source_dir=$SOURCE_RELATIVE" \
281+
--build-arg "verbose_or_quiet_flag=$VERBOSE_OR_QUIET_FLAG" \
282+
--build-arg "no_update_flag=$NO_UPDATE_FLAG" )
283+
if $QUIET; then
284+
DOCKER_ARGS+=( --quiet )
285+
fi
286+
287+
docker build "${DOCKER_ARGS[@]}" .
274288
docker run --rm -it -p 8080:80 whatwg-html
275289
exit 0
276290
fi
277291

278292

279293
$QUIET || echo "Linting the source file..."
280-
./lint.sh $HTML_SOURCE/source || {
294+
./lint.sh "$HTML_SOURCE/source" || {
281295
echo
282296
echo "There were lint errors. Stopping."
283297
exit 1
284298
}
285299

286-
rm -rf $HTML_TEMP && mkdir -p $HTML_TEMP
287-
rm -rf $HTML_OUTPUT && mkdir -p $HTML_OUTPUT
300+
rm -rf "$HTML_TEMP" && mkdir -p "$HTML_TEMP"
301+
rm -rf "$HTML_OUTPUT" && mkdir -p "$HTML_OUTPUT"
288302

289-
if [ -d $HTML_CACHE ]; then
290-
PREV_BUILD_SHA=$( cat $HTML_CACHE/last-build-sha.txt 2>/dev/null || echo "" )
303+
if [ -d "$HTML_CACHE" ]; then
304+
PREV_BUILD_SHA=$( cat "$HTML_CACHE/last-build-sha.txt" 2>/dev/null || echo )
291305
CURRENT_BUILD_SHA=$( git rev-parse HEAD )
292306

293307
if [ "$PREV_BUILD_SHA" != "$CURRENT_BUILD_SHA" ]; then
294308
$QUIET || echo "Build tools have been updated since last run; clearing the cache..."
295309
DO_UPDATE=true
296-
rm -rf $HTML_CACHE
297-
mkdir -p $HTML_CACHE
298-
echo $CURRENT_BUILD_SHA > $HTML_CACHE/last-build-sha.txt
310+
rm -rf "$HTML_CACHE"
311+
mkdir -p "$HTML_CACHE"
312+
echo "$CURRENT_BUILD_SHA" > "$HTML_CACHE/last-build-sha.txt"
299313
fi
300314
else
301-
mkdir -p $HTML_CACHE
315+
mkdir -p "$HTML_CACHE"
316+
fi
317+
318+
CURL_ARGS=()
319+
if ! $VERBOSE; then
320+
CURL_ARGS+=( --silent )
302321
fi
303322

304-
if [ "$DO_UPDATE" == true ] || [ ! -f $HTML_CACHE/caniuse.json ]; then
305-
rm -f $HTML_CACHE/caniuse.json
323+
CURL_CANIUSE_ARGS=( ${CURL_ARGS[@]} --output "$HTML_CACHE/caniuse.json" -k )
324+
CURL_W3CBUGS_ARGS=( ${CURL_ARGS[@]} --output "$HTML_CACHE/w3cbugs.csv" )
325+
326+
if [ "$DO_UPDATE" == true ] || [ ! -f "$HTML_CACHE/caniuse.json" ]; then
327+
rm -f "$HTML_CACHE/caniuse.json"
306328
$QUIET || echo "Downloading caniuse data..."
307-
curl $($VERBOSE || echo "-s") \
308-
-o $HTML_CACHE/caniuse.json -k \
329+
curl "${CURL_CANIUSE_ARGS[@]}" \
309330
https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json
310331
fi
311332

312-
if [ "$DO_UPDATE" == true ] || [ ! -f $HTML_CACHE/w3cbugs.csv ]; then
313-
rm -f $HTML_CACHE/w3cbugs.csv
333+
if [ "$DO_UPDATE" == true ] || [ ! -f "$HTML_CACHE/w3cbugs.csv" ]; then
334+
rm -f "$HTML_CACHE/w3cbugs.csv"
314335
$QUIET || echo "Downloading list of W3C bugzilla bugs..."
315-
curl $($VERBOSE || echo "-s") \
316-
-o $HTML_CACHE/w3cbugs.csv \
336+
curl "${CURL_W3CBUGS_ARGS[@]}" \
317337
'https://www.w3.org/Bugs/Public/buglist.cgi?columnlist=bug_file_loc,short_desc&query_format=advanced&resolution=---&ctype=csv&status_whiteboard=whatwg-resolved&status_whiteboard_type=notregexp&bug_file_loc=http&bug_file_loc_type=substring&product=WHATWG&product=HTML%20WG&product=CSS&product=WebAppsWG'
318338
fi
319339

320340
$QUIET || echo "Pre-processing the source..."
321-
cp -p entities/out/entities.inc $HTML_CACHE
322-
cp -p entities/out/entities-dtd.url $HTML_CACHE
323-
cp -p quotes/out/cldr.inc $HTML_CACHE
324-
perl .pre-process-main.pl $($VERBOSE && echo "--verbose") < $HTML_SOURCE/source > $HTML_TEMP/source-expanded-1
325-
perl .pre-process-annotate-attributes.pl < $HTML_TEMP/source-expanded-1 > $HTML_TEMP/source-expanded-2 # this one could be merged
326-
perl .pre-process-tag-omission.pl < $HTML_TEMP/source-expanded-2 | perl .pre-process-index-generator.pl > $HTML_TEMP/source-whatwg-complete # this one could be merged
341+
cp -p entities/out/entities.inc "$HTML_CACHE"
342+
cp -p entities/out/entities-dtd.url "$HTML_CACHE"
343+
cp -p quotes/out/cldr.inc "$HTML_CACHE"
344+
if $VERBOSE; then
345+
perl .pre-process-main.pl --verbose < "$HTML_SOURCE/source" > "$HTML_TEMP/source-expanded-1"
346+
else
347+
perl .pre-process-main.pl < "$HTML_SOURCE/source" > "$HTML_TEMP/source-expanded-1"
348+
fi
349+
perl .pre-process-annotate-attributes.pl < "$HTML_TEMP/source-expanded-1" > "$HTML_TEMP/source-expanded-2" # this one could be merged
350+
perl .pre-process-tag-omission.pl < "$HTML_TEMP/source-expanded-2" | perl .pre-process-index-generator.pl > "$HTML_TEMP/source-whatwg-complete" # this one could be merged
327351

328352
function runWattsi {
329353
# Input arguments: $1 is the file to run wattsi on, $2 is a directory for wattsi to write output to
@@ -332,74 +356,89 @@ function runWattsi {
332356
# - $HTML_TEMP/wattsi-output directory will contain the output from wattsi on success
333357
# - $HTML_TEMP/wattsi-output.txt will contain the output from wattsi, on both success and failure
334358

335-
rm -rf $2
336-
mkdir $2
359+
rm -rf "$2"
360+
mkdir "$2"
337361

362+
WATTSI_ARGS=()
363+
if $QUIET; then
364+
WATTSI_ARGS+=( --quiet )
365+
fi
366+
WATTSI_ARGS+=( "$1" "$2" "$HTML_CACHE/caniuse.json" "$HTML_CACHE/w3cbugs.csv" )
338367
if hash wattsi 2>/dev/null; then
339-
WATTSI_RESULT=$(wattsi $($QUIET && echo "--quiet") $1 $2 \
340-
$HTML_CACHE/caniuse.json $HTML_CACHE/w3cbugs.csv \
341-
> $HTML_TEMP/wattsi-output.txt; echo $?)
368+
WATTSI_RESULT=$(wattsi "${WATTSI_ARGS[@]}" \
369+
> "$HTML_TEMP/wattsi-output.txt"; echo $?)
342370
else
343371
$QUIET || echo
344372
$QUIET || echo "Local wattsi is not present; trying the build server..."
345373

346-
curl $($VERBOSE && echo "-v") $($QUIET && echo "-s") \
347-
https://build.whatwg.org/wattsi \
348-
--form source=@$1 \
349-
--form caniuse=@$HTML_CACHE/caniuse.json \
350-
--form w3cbugs=@$HTML_CACHE/w3cbugs.csv \
351-
--dump-header $HTML_TEMP/wattsi-headers.txt \
352-
--output $HTML_TEMP/wattsi-output.zip
374+
CURL_ARGS=( https://build.whatwg.org/wattsi \
375+
--form "source=@$1" \
376+
--form "caniuse=@$HTML_CACHE/caniuse.json" \
377+
--form "w3cbugs=@$HTML_CACHE/w3cbugs.csv" \
378+
--dump-header "$HTML_TEMP/wattsi-headers.txt" \
379+
--output "$HTML_TEMP/wattsi-output.zip" )
380+
if $VERBOSE; then
381+
CURL_ARGS+=( --verbose )
382+
elif $QUIET; then
383+
CURL_ARGS+=( --silent )
384+
fi
385+
curl "${CURL_ARGS[@]}"
353386

354387
# read exit code from the Wattsi-Exit-Code header and assume failure if not found
355388
WATTSI_RESULT=1
356-
while IFS=":" read NAME VALUE; do
389+
while IFS=":" read -r NAME VALUE; do
357390
if [ "$NAME" == "Wattsi-Exit-Code" ]; then
358-
WATTSI_RESULT=$(echo $VALUE | tr -d ' \r\n')
391+
WATTSI_RESULT=$(echo "$VALUE" | tr -d ' \r\n')
359392
break
360393
fi
361-
done < $HTML_TEMP/wattsi-headers.txt
394+
done < "$HTML_TEMP/wattsi-headers.txt"
362395

363396
if [ "$WATTSI_RESULT" != "0" ]; then
364-
mv $HTML_TEMP/wattsi-output.zip $HTML_TEMP/wattsi-output.txt
397+
mv "$HTML_TEMP/wattsi-output.zip" "$HTML_TEMP/wattsi-output.txt"
365398
else
366-
unzip $($VERBOSE && echo "-v" || echo "-qq") $HTML_TEMP/wattsi-output.zip -d $2
367-
mv $2/output.txt $HTML_TEMP/wattsi-output.txt
399+
UNZIP_ARGS=()
400+
# Note: Don't use the -v flag; it doesn't work in combination with -d
401+
if ! $VERBOSE; then
402+
UNZIP_ARGS+=( -qq )
403+
fi
404+
UNZIP_ARGS+=( "$HTML_TEMP/wattsi-output.zip" -d "$2" )
405+
unzip "${UNZIP_ARGS[@]}"
406+
mv "$2/output.txt" "$HTML_TEMP/wattsi-output.txt"
368407
fi
369408
fi
370409
}
371410

372-
runWattsi $HTML_TEMP/source-whatwg-complete $HTML_TEMP/wattsi-output
411+
runWattsi "$HTML_TEMP/source-whatwg-complete" "$HTML_TEMP/wattsi-output"
373412
if [ "$WATTSI_RESULT" == "0" ]; then
374-
$QUIET || cat $HTML_TEMP/wattsi-output.txt | grep -v '^$' # trim blank lines
413+
"$QUIET" || grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
375414
else
376-
cat $HTML_TEMP/wattsi-output.txt | grep -v '^$' # trim blank lines
415+
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
377416
if [ "$WATTSI_RESULT" == "65" ]; then
378417
echo
379418
echo "There were errors. Running again to show the original line numbers."
380419
echo
381-
runWattsi $HTML_SOURCE/source $HTML_TEMP/wattsi-raw-source-output
382-
cat $HTML_TEMP/wattsi-output.txt | grep -v '^$' # trim blank lines
420+
runWattsi "$HTML_SOURCE/source" "$HTML_TEMP/wattsi-raw-source-output"
421+
grep -v '^$' "$HTML_TEMP/wattsi-output.txt" # trim blank lines
383422
fi
384423
echo
385424
echo "There were errors. Stopping."
386-
exit $WATTSI_RESULT
425+
exit "$WATTSI_RESULT"
387426
fi
388427

389-
cat $HTML_TEMP/wattsi-output/index-html | perl .post-process-partial-backlink-generator.pl > $HTML_OUTPUT/index.html;
390-
cp -p entities/out/entities.json $HTML_OUTPUT
428+
perl .post-process-partial-backlink-generator.pl "$HTML_TEMP/wattsi-output/index-html" > "$HTML_OUTPUT/index.html";
429+
cp -p entities/out/entities.json "$HTML_OUTPUT"
391430

392431
# multipage setup
393-
rm -rf $HTML_OUTPUT/multipage
394-
mv $HTML_TEMP/wattsi-output/multipage-html $HTML_OUTPUT/multipage
395-
rm -rf $HTML_TEMP
396-
397-
cp -p $HTML_SOURCE/.htaccess $HTML_OUTPUT
398-
cp -p $HTML_SOURCE/404.html $HTML_OUTPUT
399-
cp -pR $HTML_SOURCE/fonts $HTML_OUTPUT
400-
cp -pR $HTML_SOURCE/images $HTML_OUTPUT
401-
cp -pR $HTML_SOURCE/demos $HTML_OUTPUT
402-
cp -pR $HTML_SOURCE/link-fixup.js $HTML_OUTPUT
432+
rm -rf "$HTML_OUTPUT/multipage"
433+
mv "$HTML_TEMP/wattsi-output/multipage-html" "$HTML_OUTPUT/multipage"
434+
rm -rf "$HTML_TEMP"
435+
436+
cp -p "$HTML_SOURCE/.htaccess" "$HTML_OUTPUT"
437+
cp -p "$HTML_SOURCE/404.html" "$HTML_OUTPUT"
438+
cp -pR "$HTML_SOURCE/fonts" "$HTML_OUTPUT"
439+
cp -pR "$HTML_SOURCE/images" "$HTML_OUTPUT"
440+
cp -pR "$HTML_SOURCE/demos" "$HTML_OUTPUT"
441+
cp -pR "$HTML_SOURCE/link-fixup.js" "$HTML_OUTPUT"
403442

404443
$QUIET || echo
405444
$QUIET || echo "Success!"

lint.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ if [ "$#" -ne 1 ]; then
77
fi
88

99
# show potential problems
10-
MATCHES=$(grep -ni 'xxx' $1 | perl -lpe 'print "\nPossible incomplete sections:" if $. == 1'
11-
grep -niE '( (code|span|var)(>| data-x=)|[^<;]/(code|span|var)>)' $1 | perl -lpe 'print "\nPossible copypasta:" if $. == 1'
12-
perl -ne '$/ = "\n\n"; print "$_" if (/chosing|approprate|occured|elemenst|\bteh\b|\blabelled\b|\blabelling\b|\bhte\b|taht|linx\b|speciication|attribue|kestern|horiontal|\battribute\s+attribute\b|\bthe\s+the\b|\bthe\s+there\b|\bfor\s+for\b|\bor\s+or\b|\bany\s+any\b|\bbe\s+be\b|\bwith\s+with\b|\bis\s+is\b/si)' $1 | perl -lpe 'print "\nPossible typos:" if $. == 1'
13-
grep -niE '((anonym|author|categor|custom|emphas|initial|local|minim|neutral|normal|optim|raster|real|recogn|roman|serial|standard|summar|synchron|synthes|token|optim)is(e|ing|ation|ability)|(col|behavi|hono|fav)our)' $1 | grep -vE "\ben-GB\b" | perl -lpe 'print "\nen-GB spelling (use lang=\"en-GB\", or <!-- en-GB -->, on the same line to override):" if $. == 1'
14-
perl -ne '$/ = "\n\n"; print "$_" if (/\ban\s+(<[^>]*>)*(?!(L\b|http|https|href|hgroup|rb|rp|rt|rtc|li|xml|svg|svgmatrix|hour|hr|xhtml|xslt|xbl|nntp|mpeg|m[ions]|mtext|merror|h[1-6]|xmlns|xpath|s|x|sgml|huang|srgb|rsa|only|option|optgroup)\b|html)[b-df-hj-np-tv-z]/si or /\b(?<![<\/;])a\s+(?!<!--grammar-check-override-->)(<[^>]*>)*(?!&gt|one)(?:(L\b|http|https|href|hgroup|rt|rp|li|xml|svg|svgmatrix|hour|hr|xhtml|xslt|xbl|nntp|mpeg|m[ions]|mtext|merror|h[1-6]|xmlns|xpath|s|x|sgml|huang|srgb|rsa|only|option|optgroup)\b|html|[aeio])/si)' $1 | perl -lpe 'print "\nPossible grammar problem: \"a\" instead of \"an\" or vice versa (to override, use e.g. \"a <!--grammar-check-override-->apple\"):" if $. == 1'
15-
grep -ni 'and/or' $1 | perl -lpe 'print "\nOccurrences of making Ms2ger unhappy and/or annoyed:" if $. == 1'
16-
grep -niE '\s+$' $1 | perl -lpe 'print "\nTrailing whitespace:" if $. == 1'
17-
perl -ne '$/ = "\n\n"; print "$_" if (/class="?(note|example).+(\n.+)*\s+(should|must|may|optional|recommended)(\s|$)/mi)' $1 | perl -lpe 'print "\nRFC2119 keyword in example or note (use: might, can, has to, or override with <!--non-normative-->must):" if $. == 1')
10+
MATCHES=$(grep -ni 'xxx' "$1" | perl -lpe 'print "\nPossible incomplete sections:" if $. == 1'
11+
grep -niE '( (code|span|var)(>| data-x=)|[^<;]/(code|span|var)>)' "$1" | perl -lpe 'print "\nPossible copypasta:" if $. == 1'
12+
perl -ne '$/ = "\n\n"; print "$_" if (/chosing|approprate|occured|elemenst|\bteh\b|\blabelled\b|\blabelling\b|\bhte\b|taht|linx\b|speciication|attribue|kestern|horiontal|\battribute\s+attribute\b|\bthe\s+the\b|\bthe\s+there\b|\bfor\s+for\b|\bor\s+or\b|\bany\s+any\b|\bbe\s+be\b|\bwith\s+with\b|\bis\s+is\b/si)' "$1" | perl -lpe 'print "\nPossible typos:" if $. == 1'
13+
grep -niE '((anonym|author|categor|custom|emphas|initial|local|minim|neutral|normal|optim|raster|real|recogn|roman|serial|standard|summar|synchron|synthes|token|optim)is(e|ing|ation|ability)|(col|behavi|hono|fav)our)' "$1" | grep -vE "\ben-GB\b" | perl -lpe 'print "\nen-GB spelling (use lang=\"en-GB\", or <!-- en-GB -->, on the same line to override):" if $. == 1'
14+
perl -ne '$/ = "\n\n"; print "$_" if (/\ban\s+(<[^>]*>)*(?!(L\b|http|https|href|hgroup|rb|rp|rt|rtc|li|xml|svg|svgmatrix|hour|hr|xhtml|xslt|xbl|nntp|mpeg|m[ions]|mtext|merror|h[1-6]|xmlns|xpath|s|x|sgml|huang|srgb|rsa|only|option|optgroup)\b|html)[b-df-hj-np-tv-z]/si or /\b(?<![<\/;])a\s+(?!<!--grammar-check-override-->)(<[^>]*>)*(?!&gt|one)(?:(L\b|http|https|href|hgroup|rt|rp|li|xml|svg|svgmatrix|hour|hr|xhtml|xslt|xbl|nntp|mpeg|m[ions]|mtext|merror|h[1-6]|xmlns|xpath|s|x|sgml|huang|srgb|rsa|only|option|optgroup)\b|html|[aeio])/si)' "$1" | perl -lpe 'print "\nPossible grammar problem: \"a\" instead of \"an\" or vice versa (to override, use e.g. \"a <!--grammar-check-override-->apple\"):" if $. == 1'
15+
grep -ni 'and/or' "$1" | perl -lpe 'print "\nOccurrences of making Ms2ger unhappy and/or annoyed:" if $. == 1'
16+
grep -niE '\s+$' "$1" | perl -lpe 'print "\nTrailing whitespace:" if $. == 1'
17+
perl -ne '$/ = "\n\n"; print "$_" if (/class="?(note|example).+(\n.+)*\s+(should|must|may|optional|recommended)(\s|$)/mi)' "$1" | perl -lpe 'print "\nRFC2119 keyword in example or note (use: might, can, has to, or override with <!--non-normative-->must):" if $. == 1')
1818

1919
if [ -n "$MATCHES" ]; then
2020
echo "$MATCHES"

0 commit comments

Comments
 (0)