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

Re: print to the terminal in zle

2013-07-26 20:39:31 +0100, Peter Stephenson:
> On Fri, 26 Jul 2013 14:48:11 +0100
> Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
> > recently, Debian broke some of my scripts using ZLE in `zsh -i` by adding:
> > 
> >         function zle-line-init () {
> >             emulate -L zsh
> >             printf '%s' ${terminfo[smkx]}
> >         }
> > 
> > To /etc/zsh/zshrc
> > 
> > That smkx  escape sequence is printed to stdout instead of the terminal.
> It's just occurred to me that maybe zle special functions should be run
> with stdout and stdin set explicitly to the terminal.  Arguably they
> have no business knowing about a redirected stdout or stdin since they
> run in a context where that's meaningless.  stderr would be good enough
> for debugging.

In my script (http://www.zsh.org/mla/users/2007/msg01187.html),
I need to be able to access stdout from a zle function, though I
could change it to use another fd (my modified "accept-line"
writes the $BUFFER to stdout that goes to a pipe) (and yes,
there was a reason to write it in such a convoluted way, but
that was years ago)

Given that ZLE can be used from "vared" to implement a line
editor for something else than the shell prompt, where a system
of functions can be defined by the user, it feels wrong to hide
stdout from those functions.

Think of

vared var | {
  some processing that interacts with what widgets write to

Now, I agree it's a clean way to expose the terminal to the ZLE
widgets would they need to send/recv data to/from it, and one
can dup to another fd if they need to access the original

vared var 3>&1 | ...

or use a coproc...


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