Skip to content

Commit

Permalink
Fix bug in reserved name matching
Browse files Browse the repository at this point in the history
The regexp for matching reserved names didn't start with '^', which
means file names with matching substrings triggered it.  A file named
"icon.gif" shouldn't trigger this because "con" is in the name.  The
fix prevents this problem.
  • Loading branch information
mhucka committed Mar 11, 2020
1 parent ba73751 commit 97ee8d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dev/git-tools/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ git diff --cached --name-only --diff-filter=A -z $against | while IFS= read -r -

# Reserved names plus possible extension
# CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9
reservednames=$(echo -n "$filename" | LC_ALL=C grep -i -E '(CON|PRN|AUX|NUL|COM1|COM2|COM3|COM4|COM5|COM6|COM7|COM8|COM9|LPT1|LPT2|LPT3|LPT4|LPT5|LPT6|LPT7|LPT8|LPT9).[a-z]{3}' | wc -c)
reservednames=$(echo -n "$filename" | LC_ALL=C grep -i -E '^(CON|PRN|AUX|NUL|COM1|COM2|COM3|COM4|COM5|COM6|COM7|COM8|COM9|LPT1|LPT2|LPT3|LPT4|LPT5|LPT6|LPT7|LPT8|LPT9).[a-z]{3}' | wc -c)

# No trailing period or space
trailingperiodorspace=$(echo -n "$filename" | LC_ALL=C grep -E '(\.| )$' | wc -c)
Expand Down

0 comments on commit 97ee8d0

Please sign in to comment.