I'm trying to implement an option to skip a pre-commit hook (which will be considered pass and perform the commit) in a pre-commit hook.
Everything is running fine except the prompt which reads an empty string ("") and thus the switch is going to the default "invalid argument" which leads into an infinite loop.
I guess there is something I don't understand about how pre-commit works which result in this behavior. Could you please illuminate me and if possible hint at a solution?
while true; do
read -p "Do you want to run pre-commit hook? (N=pass) [Y/N]: " choice
#tried alternative approach, but no success.
#echo "Do you want to run pre-commit hook? (N=pass) [Y/N]: "
#read choice
echo "Debug: response=\"$choice\""
case $choice in
[Yy]* )
echo "Running pre-commit hook...";
break;;
[Nn]* )
echo "Skipping pre-commit hook. This is evaluated as passed.";
exit 0;;
* )
echo "Invalid input. Please enter 'y' or 'n'.";;
esac
done
/dev/ttytrick in a hook. You get strange errors as soon as you try to run it in some non-shell like an IDE.