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

Re: Using zle outside zsh



On Tue, 24 Aug 2004, DervishD wrote:

>     Yes, my fault, but that doesn't solve the problem :( With that
> change the first read works but the second doesn't.

You didn't read/copy precisely enough, Raúl.

> # This worked as before since the line is exactly 'ftp> '.
> # Same for telnet
> zpty -r ftp response '(|*\n)ftp> '

zpty -r ftp response $'(|*\n)ftp> '

Note the dollar-sign.  Without that the \n is not converted to a newline.

Also, you do NOT want "zpty -b".  It makes the PTY non-blocking in *both*
directions, which confuses ftp into insanity.  It may even have exited by
the time you first try to write to it.

As for other reads hanging forever ... well, "ftp> " isn't the only prompt
that might be printed.  It may be asking for a username or a password, for
example, and "password: " won't match the pattern.  Try something like

zpty -r ftp response $'(|*\n)(ftp> |*[[:punct:]]: |Password:)'

Finally, vared is probably printing a carriage return and thereby erasing 
the last line of the "print -nr" output, which might fool you into 
thinking the read is hung.  So pick the last line out of $response and
pass that to vared as the prompt, like so:

pmpt=${response##$'*\n'}

while line=''; vared -e -p $pmpt line
do
  ...
  pmpt=${response##$'*\n'}
done


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