run-codespell: Fix invocation with multiple arguments.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-10-27 17:51:22 -07:00 committed by Tim Abbott
parent a3a71487b0
commit 8bb540fa31
1 changed files with 5 additions and 5 deletions

View File

@ -7,16 +7,16 @@
# We plan to replace this script with the `tools/lint` system as soon as we can. # We plan to replace this script with the `tools/lint` system as soon as we can.
IGNORE_WORDS_FILE=.codespellignore IGNORE_WORDS_FILE=.codespellignore
FILES_TO_BE_CHECKED=$* if [ "$#" -eq 0 ]; then
if [ -z "$FILES_TO_BE_CHECKED" ]; then
echo "No argument specified. Checking on the entire repo..." echo "No argument specified. Checking on the entire repo..."
FILES_TO_BE_CHECKED="$(git ls-files -- ':(exclude)locale' ':(exclude)*fixtures*' ':(exclude)*.svg' ':(exclude)docs/translating' ':(exclude)yarn.lock' ':(exclude)docs/THIRDPARTY' ':(exclude)*postgresql.conf.template.erb' ':(exclude)tools/setup/emoji/emoji_names.py' ':(exclude)tools/setup/emoji/emoji_map.json' ':(exclude)zerver/management/data/unified_reactions.json')" FILES_TO_BE_CHECKED="$(git ls-files -- ':(exclude)locale' ':(exclude)*fixtures*' ':(exclude)*.svg' ':(exclude)docs/translating' ':(exclude)yarn.lock' ':(exclude)docs/THIRDPARTY' ':(exclude)*postgresql.conf.template.erb' ':(exclude)tools/setup/emoji/emoji_names.py' ':(exclude)tools/setup/emoji/emoji_map.json' ':(exclude)zerver/management/data/unified_reactions.json')"
mapfile -t FILES_TO_BE_CHECKED <<<"$FILES_TO_BE_CHECKED"
else else
echo "Checking $FILES_TO_BE_CHECKED" FILES_TO_BE_CHECKED=("$@")
echo "Checking ${FILES_TO_BE_CHECKED[*]@Q}"
fi fi
mapfile -t FILES_TO_BE_CHECKED <<<"$FILES_TO_BE_CHECKED"
if ! codespell --ignore-words=$IGNORE_WORDS_FILE "${FILES_TO_BE_CHECKED[@]}"; then if ! codespell --ignore-words="$IGNORE_WORDS_FILE" -- "${FILES_TO_BE_CHECKED[@]}"; then
echo "You may check the files for typo again using ./tools/run-codespell <file 1> <file 2> ... <file n>" echo "You may check the files for typo again using ./tools/run-codespell <file 1> <file 2> ... <file n>"
exit 1 exit 1
fi fi