zsh-workers
 help / color / mirror / code / Atom feed
* zpty
@ 2004-03-17 12:58 Oliver Kiddle
  2004-03-17 13:57 ` zpty Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2004-03-17 12:58 UTC (permalink / raw)
  To: Zsh workers

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 \


^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <20030829110333.GB2661@julia.office.altlinux.ru>]

end of thread, other threads:[~2004-03-17 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-17 12:58 zpty Oliver Kiddle
2004-03-17 13:57 ` zpty Peter Stephenson
     [not found] <20030829110333.GB2661@julia.office.altlinux.ru>
2003-08-30 19:33 ` zpty Peter Stephenson
2003-09-01  9:21 ` zpty Borzenkov Andrey

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).