Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 'read -q -t X'
- X-seq: zsh-users 14250
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: 'read -q -t X'
- Date: Fri, 24 Jul 2009 09:43:57 +0100
- In-reply-to: <alpine.DEB.2.00.0907231851500.2551@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <alpine.DEB.2.00.0907231851500.2551@xxxxxxxxxxxxxxx>
"Michael B. Trausch" wrote:
>
> I'd like to use read with the -q and -toptions together, like so:
>
> read -q -t 10 '?Load Screen? (10 seconds, default Y) [Y/n] '
>
> And have it read a y or n, but timeout the read if it's not answered in 10
> seconds. I am doing this to have my login shells not always kick other ones
> off, as I use GNU screen for when I login from my phone, but not (usually)
> otherwise (and not always on the phone, sometimes I move it).
>
> Is there a way to do this? It seems that combining -q and -t results in
> weirdness that ultimately doesn't work.
I think the nearest you can get for now is use read -k -t 10 ... and
interpret the character yourself on a successful read. This is a bug:
-q and -k should be similar enough that the shell does essentially that
internally. Unfortunately, every time anyone has added a "great new
feature" to the read builtin they've simply hacked it in as a completely
separate case without fitting it properly into the existing code, so the
-t code isn't wired up to treat -q as a special case, unlike -k.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
'member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author