Skip to content

support files with (some) sorts of special characters in them #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
# This program is in the public domain

function typeof () {
filename=$1
case $filename in
filename="$1"
case "$filename" in
*.pl | *.pm) echo perl; exit ;;
esac

line1=$(head -1 $1)
case $line1 in '#!'*perl )
case "$line1" in '#!'*perl )
echo perl; exit ;;
esac
}

if [ ! -z $COMMIT_OK ]; then
if [ ! -z "$COMMIT_OK" ]; then
exit 0;
fi

Expand All @@ -39,8 +39,8 @@ for file in $(git diff --cached --name-only | sort) ; do
echo "## Checking file $file (type $type)"
case $type in
perl )
perl -cw $file || BAD=true
[ -x $file ] || { echo "File is not executable"; BAD=true; }
perl -cw -- "$file" || BAD=true
[ -x "$file" ] || { echo "File is not executable"; BAD=true; }
;;
* )
echo "Unknown file type: $file; no checks"
Expand All @@ -57,7 +57,7 @@ if $allOK; then
else
echo ''
echo '## Aborting commit. Failed checks:'
for file in $(echo $badFiles | tr ';' ' '); do
for file in $(echo "$badFiles" | tr ';' ' '); do
echo " $file"
done
exit 1;
Expand Down