Skip to content

Commit 8c001ee

Browse files
committed
Unset locale while pattern matching
This commit resolves the "Invalid collation character" error thrown by 'grep' when validating directory names with special characters. It sets locale to "C" before running 'grep'. Change-Id: Ia005744cfc1799dff0148602bcb99d947f8c805d
1 parent e427460 commit 8c001ee

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

scripts/commit-msg.hook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ validate_commit_message() {
476476

477477
# Alert if the commit message appears to be written in Chinese.
478478
# This pattern matches any Chinese character (common CJK Unified Ideographs).
479-
MISSPELLED_WORDS=$(echo "$FULL_COMMIT_MSG" | grep "[一-龥]")
479+
MISSPELLED_WORDS=$(echo "$FULL_COMMIT_MSG" | LC_ALL=C grep "[一-龥]")
480480
if [ -n "$MISSPELLED_WORDS" ]; then
481481
add_warning 1 "Commit message appears to be written in Chinese: $MISSPELLED_WORDS"
482482
fi

scripts/pre-commit.hook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ RETURN=0
9999

100100
# Disallow non-ASCII characters in workspace path
101101
workspace=$(git rev-parse --show-toplevel)
102-
if echo "$workspace" | grep -q "[一-龥]"; then
102+
if echo "$workspace" | LC_ALL=C grep -q "[一-龥]"; then
103103
throw "The workspace path '$workspace' contains non-ASCII characters."
104104
fi
105105

0 commit comments

Comments
 (0)