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

Re: Could multios response positively to isatty(1) test?



On Thu, 7 Feb 2019 at 16:10, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
>
> On Thu, 2019-02-07 at 14:18 +0100, Sebastian Gniazdowski wrote:
> > Hello,
> > If at least one of the outputs of the multios-utilizing invocation is
> > to a terminal, .e.g
> >
> > print "$fg[blue]A TEST$reset_color" \
> >     > >(ansifilter >>! "log.txt") 1> >/dev/tty
> >
> > then could Zshell answer positively to the isatty(1) test for the
> > application (like e.g. vim) placed the way that the print-command is?
> > Is this doable?
>
> The short answer's no.  Implementing pty support in the core shell would
> be a bug-prone maintenance disaster.

Implementing isn;'t necessary – what's needed is the knowledge, that
original fd=1 is a tty,, and conveying that lfurther to the zsh
process realizing the multios – i.e.: conveying only the test answer
to isatty(fd=1), not the terminal implementation. Simple forwarding of
all data to the terminal through non-terminal. works (a good test: vim
| cat).

I wonder what the test (isatty(1)) does. Does it invoke some ioctl()
that somehow reaches the zsh multios-process.. No rather not, but what
then? Maybe some flag on the fd: that is visible to the
application/writer?

> You're best bet is some kind of pty wrapper (as already discussed) plus
> something looking a bit like tee.  This is not stuff you want within zsh
> (unless as an add-on --- but zpty is bad enough to maintain, so I wouldn't
> recommend even that).
>
> pws
>

--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org



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