From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22486 invoked from network); 17 Mar 2004 12:59:33 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 17 Mar 2004 12:59:33 -0000 Received: (qmail 26312 invoked by alias); 17 Mar 2004 12:59:21 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19648 Received: (qmail 26297 invoked from network); 17 Mar 2004 12:59:21 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 17 Mar 2004 12:59:21 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [193.109.254.211] by sunsite.dk (MessageWall 1.0.8) with SMTP; 17 Mar 2004 12:59:21 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-22.tower-36.messagelabs.com!1079528360!4694668 X-StarScan-Version: 5.2.5; banners=-,-,- X-Originating-IP: [158.234.9.163] Received: (qmail 21557 invoked from network); 17 Mar 2004 12:59:20 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-22.tower-36.messagelabs.com with SMTP; 17 Mar 2004 12:59:20 -0000 Received: from trentino.logica.co.uk ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id i2HCxJCk005258 for ; Wed, 17 Mar 2004 12:59:20 GMT Received: from trentino.logica.co.uk (localhost [127.0.0.1]) by trentino.logica.co.uk (Postfix) with ESMTP id A15A879721C1 for ; Wed, 17 Mar 2004 13:58:35 +0100 (CET) X-VirusChecked: Checked X-StarScan-Version: 5.1.13; banners=.,-,- From: Oliver Kiddle To: Zsh workers Subject: zpty Date: Wed, 17 Mar 2004 13:58:35 +0100 Message-ID: <12085.1079528315@trentino.logica.co.uk> 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 \