Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Sep 1997 07:58:02 -0500
From:      Jon Hamilton <hamilton@pobox.com>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Timeout for sh(1) 'read' ?? 
Message-ID:  <199709261259.FAA03276@hub.freebsd.org>
In-Reply-To: Your message of "Fri, 26 Sep 1997 11:59:14 -0000." <199709261159.EAA20125@usr09.primenet.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

In message <199709261159.EAA20125@usr09.primenet.com>, Terry Lambert writes:
} > Hiho folks, a question for the sh(1) studs amongst you :
} > 
} >  - I want to prompt for input using 'read', and have the read return in
} >    some fashion after a timeout.
} > 
} > I'd like to do this just using sh, and I'm not too fussed about how 
} > hairy it is.  Any ideas?
} > 
} > (If sh has to be modified to achieve this, would it be a useful thing 
} > to bring back?)
} 
} Write a "timedread" program that returns "TIMEOUT" or "USERDATA xxxxx"
} and do "timedread | read x" and look at the front of x?  8-) 8-).

Which will of course execute in a subshell because of the pipe and wind
up doing you no good.  

You can do this kind of thing with background processes and trap, but
it's not what you'd call pretty, and even that isn't as straightforward
as it might sound.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709261259.FAA03276>