You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# - Escaped line continuations (trailing backslash)
417
420
# NOTE: filename exclusion is handled in the perl regex via (?!\.)
418
421
# so that 'colors' in a comment is fixed even if 'colours.sh' appears on the same line
419
-
if echo "$line" | grep -qE "(=[\"'](center|color)|types:[[:space:]]*\[[^]]+\]|--[a-z-]+ (center|color|gray)|--color|--center|\\$\\{?(color|center|gray)|\\b(COLOR|CENTER|GRAY)[_A-Z]*=|gum |\\\\$)"; then
422
+
if echo "$line" | grep -qE "(https?://|github/|[?&](color|center|gray|licence)=|=[\"'](center|color|licence)|types:[[:space:]]*\[[^]]+\]|--[a-z-]+ (center|color|gray)|--color|--center|\$\{?(color|center|gray|licence)|\b(COLOR|CENTER|GRAY|LICENCE)[_A-Z]*=|gum |\\$|shields\.io)"; then
420
423
echo "$line"
421
424
else
422
425
# Apply case-preserving replacement using perl
423
426
# (?!\.) prevents replacing when the word is directly followed by a dot (e.g. colors.sh)
424
427
echo "$line" | perl -pe "
425
-
s/\\b${american}\\b(?!\\.)/
428
+
s{\b${american}\b(?!\.)(?![a-zA-Z0-9]|/|=)}{
426
429
my \$match = \$&;
427
430
my \$repl = '${british}';
428
-
if (\$match =~ \/^[A-Z]+\$\/) {
431
+
if (\$match =~ /^[A-Z]+\$/) {
429
432
# ALL CAPS
430
433
uc(\$repl);
431
-
} elsif (\$match =~ \/^[A-Z]\/) {
434
+
} elsif (\$match =~ /^[A-Z]/) {
432
435
# Title Case
433
436
ucfirst(\$repl);
434
437
} else {
435
438
# lowercase
436
439
\$repl;
437
440
}
438
-
/gei"
441
+
}gei"
439
442
fi
440
443
done < "$file" > "$tmpfile"
441
444
@@ -452,7 +455,7 @@ jobs:
452
455
453
456
# Check if file contains the word (case-insensitive, whole word)
454
457
# Exclude lines where the match is inside a code/CLI pattern (filename exclusion handled by perl (?!\.))
455
-
if grep -inw "$american" "$file" 2>/dev/null | grep -qvE "(https?://|[?&](color|center|gray)=[a-zA-Z0-9]+|\"Authorization\": \"Bearer|types:[[:space:]]*\[[^]]+\]|=[\"'](center|color)|--[a-z-]+ (center|color|gray)|--color|--center|\\$\\{?(color|center|gray)|\\b(COLOR|CENTER|GRAY)[_A-Z]*|gum |\\\\$)"; then
458
+
if grep -inw "$american" "$file" 2>/dev/null | grep -qvE "(https?://|file://|github/|[?&](color|center|gray|licence)=[a-zA-Z0-9]+|\"Authorization\": \"Bearer|types:[[:space:]]*\[[^]]+\]|=[\"'](center|color|licence)|--[a-z-]+ (center|color|gray)|--color|--center|\$\{?(color|center|gray|licence)|\b(COLOR|CENTER|GRAY|LICENCE)[_A-Z]*|gum |\\$|shields\.io)"; then
0 commit comments