Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: read timeout argument || completion of a function

On Aug 12, 12:43pm, Bruno Bonfils wrote:
} "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx> writes:
} > There are certain aspects of the arms race in which ksh is currently
} > ahead.  I suppose when it gets a builtin to launch satellites we'll
} > have to start working on moon landers.
} I'm don't sure to understanding you at all. (maybe my sentence is
} meaningless ?) 

I'm making a silly joke that compares features in ksh and zsh to the 1950's
space race between the USSR and the USA.

On Aug 12, 12:41pm, Peter Stephenson wrote:
} Two issues:
} (1) Getting keyboard polling to work on both UNIX and Cygwin was a
} nightmare, so the code is quite complicated.
} (2) We took -t for this (test) and we really need to make -t with a
} number work for timeouts for compatibility with everyone else.  You
} don't normally give a numeric parameter to read (though in fact it works),
} so this ought to be possible.  However, adding optional numeric
} arguments will have to wait for the current horrific handling of option
} arguments (dating from year zero and looking like it) to be tidied up.

Peter already knows this, but to elaborate:

Optional arguments of any sort are a bit messy in the zsh command flag
parsing scheme, mainly because it doesn't keep track of the order in
which the flags appear.  E.g. given "read -t 3 -k 5" the parser rewrites
it into the equivalent of "read -kt 3 5" before calling the builtin.
So you can trick it into handling one flag with an optional argument,
but not two or more such flags at once.

} (It's not just horrific internally in some cases:  I've a vague memory
} there are places which only accept `-X<arg>' and other places which only
} accept `-X <arg>'.  It's no surprise that many modules handle option
} arguments using their own code.)

The vague memory is of the `read' builtin itself, -uN and -k N.

BTW, there's this mystifying bit of code in bin_read():

    if ((ops['k'] || ops['b']) && *args && idigit(**args)) {

What the heck is ops['b'] ?  As far as I can tell there's no way for
bin_read() to ever get called with a 'b' flag, and the flag is never
mentioned anywhere else.  This 'b' code appears in my personal CVS
repository on 1997/06/27 as part of 3.0.3, but I can't find any
corresponding change to hashtable.c (where the `struct builtin' for
all builtins were defined at that time).

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author