2

For my mercurial commit hook, I want to run my test cases and be asked whether I really want to commit if any of the tests fail. I'm thinking something like <run-the-tests> || <ask-yes-no> is the way to go, except I don't know what to put in the <ask-yes-no> spot.

My best solution so far is zenity --question, but I would like something that doesn't depend on X11. Then there's dialog, but that depends on curses which is a no-go inside an emacs shell. So, I'm pretty stumped. How do I turn a yes-or-no user input into a zero-or-nonzero exit status?

1

1 Answer 1

3
$ (read -p "Foo the bar? [y/N] " ans ; [ "$ans" = Y -o "$ans" = y ]) ; echo $?
Foo the bar? [y/N] Y
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .