I have a script that is causing an issue, I've boiled it down to this;
#/bin/bash read -t 1 -p 'Wanna continue?' less +F readTimeout.sh echo 'Wont get printed'
The original script operated by prompting the user to continue, but after waiting for five seconds (in this case, one) it will continue on its own.
It then proceeds to tail from a log file (in this case, itself, for demonstrative purposes).
Then it should execute the rest of the commands after the user closes
less is in
tail mode, you need to hit ctrl+c to stop it from following the file (then you can scroll/search on what's in
less so far, or shift+f to follow again, or Q to quit).
The problem for this script is, when you
^C it kills
less, takes you back to prompt (i.e. the rest of the commands aren't ran) and stops anything you type from being echoed (if you hit enter your commands are actually being written to the console, though)!
-t switch on
read (or if you respond before the timeout) it works fine.
Any ideas why this happens &/or how to combat this? So far I've resorted to just forcing the user to respond to the prompt (i.e. removing the
timeout flag from
This is terminal emulator independent (tested
And I've tried placing
stty sane after the
read line in case it would fix it.