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

Re: Using zle outside zsh

    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> > >  So pick the last line out of $response and
> > > pass that to vared as the prompt, like so:
> > > pmpt=${response##$'*\n'}
> >     I must use "${response##*$'\n'}" or it doesn't work because the
> > '*' is quoted
> Oh, yes.  Typo on my part.  Sorry.

    Don't worry. My mistakes weren't typos O:)
> >     OTOH, I think that, for a program like 'ftp' that not only prints
> > its own set of prompts but uses some server responses as prompts, it
> > would be better to read line by line until no more lines are present
> Unfortunately there's no way to know *when* "no more lines are present". 
> It's a TTY, after all; you don't get an EOF.

    Yes, but I can use 'zpty -rt' to test if more output must be
copied. The problem with this method is that it won't read the prompt
line since it doesn't have a '\n' at the end, it's not a line!. If
the prompt was always the same, it wouldn't be a problem, but...

    It works as it is now, and the only problem is to get all the
prompts. It is a work far less complex than to write a line editor
for the ftp client ;)
> >     Seems that the only possible solutions is to know in advance all
> > possible prompts and use 'zpty -r COMMAND NAME PATTERN', or using
> > zselect, or even using a proxy program that translates and normalizes
> > all received prompts including a '\n', or something like that...
> zselect might help, because you could look for input from the keyboard
> and from the pty at the same time -- but then you can't use vared.

    I prefer to use vared by now, although I can change all
keybindings for this particular use inside the script and get rid of
vared. My version of zsh doesn't even have 'zselect', so...
> Or you could try something with "zle -F" but I don't know if that works
> inside vared (I'd presume it does, but I've never tried).

    My zsh version (4.0.9) doesn't seem to have '-F' as an option to
zle. I'll take a look in the 4.2.1 I haven't installed yet.

    Well, thanks a lot for all your help, Bart :) Now I have an
alternative to zftp with full command line editing... as soon as I do
a bit of work. Not much, fortunately :) Thanks

    Raúl Núñez de Arenas Coronado

Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/

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