Skip to content

Instantly share code, notes, and snippets.

@AurelienLoyer
Created November 20, 2018 21:18
Show Gist options
  • Save AurelienLoyer/4e9d3bdcc54031baa807cfaa009eacb5 to your computer and use it in GitHub Desktop.
Save AurelienLoyer/4e9d3bdcc54031baa807cfaa009eacb5 to your computer and use it in GitHub Desktop.
[Pre Commit Git Hook] Prevent special character in filenames #git
#!/bin/sh
for file in $(git diff --cached --name-only)
do
if [[ $file == *['!'@#éáàè\$%^\&*()+]* ]]
then
echo "pre-commit: Aborting commit due to filename with special character ($file)"
exit 1
fi
done
echo "pre-commit: No special character found :)"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment