Reputation: 51
When I do a commit, the bash script starts but doesn't wait for the user to choose
.huskyrc file
{
"hooks": {
"pre-commit": "bash scripts/pre_commit.sh"
}
}
pre_commit.sh file
#!/bin/bash
PS3='Please enter your choice: '
options=("X" "Y" "Z")
select opt in "${options[@]}"
do
case $opt in
"X")
echo "works"
exit 0
;;
"Y")
npm run test
exit 0
;;
"Z")
echo "Option Z";
exit 0
;;
*) echo "invalid option $REPLY";;
esac
done
exit 0
Upvotes: 2
Views: 4675
Reputation: 51
The answer was add befor PS3='Please enter your choice: '
if [ -t 1 ]; then
exec < /dev/tty
fi
Upvotes: 3