mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 09:59:12 +00:00
pre-commit: Workaround shell syntax limitations
Commit "Reject leading TABs" added use of shell syntax of the form $(case "..." in a) ... ;; esac) Some shell implementations fail to recognize that the ')' in the case label is not the end of the '$(' expression. Work around the problem by moving the case block into a separate function outside the '$()' expression.
This commit is contained in:
parent
f226aad5a4
commit
0df83855da
25
pre-commit
25
pre-commit
@ -58,19 +58,22 @@ check_tab() {
|
|||||||
grep '^+ ' > /dev/null &&
|
grep '^+ ' > /dev/null &&
|
||||||
echo " $1"
|
echo " $1"
|
||||||
}
|
}
|
||||||
|
check_file() {
|
||||||
|
case "$1" in
|
||||||
|
*.c) check_tab "$1" ;;
|
||||||
|
*.h) check_tab "$1" ;;
|
||||||
|
*.cxx) check_tab "$1" ;;
|
||||||
|
*.txx) check_tab "$1" ;;
|
||||||
|
*.hxx) check_tab "$1" ;;
|
||||||
|
*.htm) check_tab "$1" ;;
|
||||||
|
*.html) check_tab "$1" ;;
|
||||||
|
*.txt) check_tab "$1" ;;
|
||||||
|
*.cmake) check_tab "$1" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
bad=$(git diff-index --name-only --cached $against -- |
|
bad=$(git diff-index --name-only --cached $against -- |
|
||||||
while read file; do
|
while read file; do
|
||||||
case "$file" in
|
check_file "$file"
|
||||||
*.c) check_tab "$file" ;;
|
|
||||||
*.h) check_tab "$file" ;;
|
|
||||||
*.cxx) check_tab "$file" ;;
|
|
||||||
*.txx) check_tab "$file" ;;
|
|
||||||
*.hxx) check_tab "$file" ;;
|
|
||||||
*.htm) check_tab "$file" ;;
|
|
||||||
*.html) check_tab "$file" ;;
|
|
||||||
*.txt) check_tab "$file" ;;
|
|
||||||
*.cmake) check_tab "$file" ;;
|
|
||||||
esac
|
|
||||||
done)
|
done)
|
||||||
test -z "$bad" || die 'Leading TABs added in
|
test -z "$bad" || die 'Leading TABs added in
|
||||||
'"$bad"'
|
'"$bad"'
|
||||||
|
Loading…
Reference in New Issue
Block a user