Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Well, when 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)!

Without the -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 read)

P.S.
This is terminal emulator independent (tested konsole and xterm).
And I've tried placing stty sane after the read line in case it would fix it.

share|improve this question
    
The script works fine for me. Can you provide more details about your system? –  rici Jan 31 at 17:40
    
CentOS 6.4, what would you like to know? –  Hashbrown Feb 1 at 1:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.