I have a git hook that does some work
in a loop till the user input is y/Y
(other than n/N
).
This works fine for all (commits, merges, amends, etc). Except for rebase, I get
.git-hooks/commit-msg: line xx: /dev/tty: No such device or address
error when I reword/edit a merge commit.
Example: If I rebase -i head~4 -p
and reword all commits (that include merge commits) then I get this error on the merge commits.
hook:
#!/bin/sh
# git hook
work() {
echo "working..."
}
user_input() {
while true; do
work "$@"
echo -e -n "done?"
read -p '' ans
case $ans in
[nN] )
;;
* )
break ;;
esac
done
}
exec < /dev/tty
user_input "$@"
exec <&-