Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
zpty
- X-seq: zsh-workers 19648
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxxxxx>
- Subject: zpty
- Date: Wed, 17 Mar 2004 13:58:35 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Even using a working zpty on Linux/Solaris, it seems it has issues.
(I've never really used zpty before.)
The first thing which is easy to fix is that the completion function
was missing a couple of options. A patch for this is attached.
Anyway, try running this:
zpty test cat
zpty -L
^C
Why does zpty -L need to call checkptycmd()? Is that to see if the
process is still alive? It tries to read one character which blocks.
Also, someone might care that it loses $'\xff' characters. To be fair,
there's a comment above saying "a better process handling would be
nice". But can it be improved by using read_poll from utils.c?
That could perhaps also allow the -t option to take a timeout parameter
like read now does. However, rather than duplicating the whole of read,
the ideal would be if zpty would work more like coproc and we could
just use read, print, jobs etc to handle the commands.
Also note that you can only ever read from this cat zpty command by
hitting Ctrl-C.
Oliver
Index: Completion/Zsh/Command/_zpty
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_zpty,v
retrieving revision 1.1
diff -u -r1.1 _zpty
--- Completion/Zsh/Command/_zpty 2 Apr 2001 11:33:55 -0000 1.1
+++ Completion/Zsh/Command/_zpty 17 Mar 2004 12:42:52 -0000
@@ -5,26 +5,30 @@
_arguments -C -s -S \
- '(-r -w -L -d)-e[echo input characters]' \
- '(-r -w -L -d)-b[io to pseudo-terminal blocking]' \
- '(-r -w -L -e -b)-d[delete command]:*:name:->name' \
- '(-r -L -e -b -d)-w[send string to command]:name:->name:*:strings to write' \
- '(: -r -w -e -b -d)-L[list defined commands as calls]' \
- '(: -w -L -e -b -d)-r[read string from command]:name:->name:param: _vars:pattern:' \
- '(-r -w -L -d):zpty command name:' \
- '(-r -w -L -d):cmd: _command_names -e' \
- '(-r -w -L -d)*::args:_precommand' && return 0
+ '(-r -w -t -n -L -d)-e[echo input characters]' \
+ '(-r -w -t -n -L -d)-b[io to pseudo-terminal blocking]' \
+ '(-r -w -t -n -L -e -b)-d[delete command]:*:name:->name' \
+ '(-r -L -t -e -b -d)-w[send string to command]:name:->name:*:strings to write' \
+ '(-r -L -t -e -b -d)-n[do not add a newline to the result]' \
+ '(: -r -w -t -n -e -b -d)-L[list defined commands as calls]' \
+ '(: -w -n -L -e -b -d)-r[read string from command]:name:->name:param: _vars:pattern:' \
+ '(: -w -n -L -e -b -d)-t[test if output is available before reading]' \
+ '(-r -w -t -n -L -d):zpty command name:' \
+ '(-r -w -t -n -L -d):cmd: _command_names -e' \
+ '(-r -w -t -n -L -d)*::args:_precommand' && return 0
# One could use sets, but that's more expensive and zpty is simple enough.
#
# _arguments -C -s -S \
# - read \
# '-r[read string from command]' \
+# '-t[test if output is available first]' \
# ':name:->name' \
# ':param: _vars' \
# ':pattern:' \
# - write \
# '-w[send string to command]' \
+# '-n[do not add a newline to the result]' \
# ':name:->name' \
# '*:strings to write' \
# - list \
Messages sorted by:
Reverse Date,
Date,
Thread,
Author