I have this little example script:
for i in {1..100}; do
echo $i
sleep 0.1
done | whiptail --gauge "Doing something" 10 50 0
It works as it should, displaying a moving progress bar and quits when it reached 100.
Using the same for-loop without piping it to whiptail
, I can stop it with Ctrl+C. But how can I interactively terminate the process piping to whiptail as Ctrl+C is not working here?
I have try different optiuons with whiptail, and seems the only solution is to execute it for every percent. Ctrl-C is working.
Changing TERM is needed to make it work in
gnome-terminal
, same for xterm(tested it), and probably other terminalsTested in text console(tty) - it already have TERM=linux
whiptail
restores terminal text to same as before execution, but TERM=linux blocks this feature.If you need to output some progress information, its better to do it inside
whiptail
text parametersTo quit the program you can try something like the following:
Here the script will wait for user input 'q' or 'Q' to exit.