Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why multios affects >/dev/tty redirection?
On Thu, 2019-02-07 at 14:00 +0100, Sebastian Gniazdowski wrote:
> On Tue, 5 Feb 2019 at 17:43, Philippe Troin <phil@xxxxxxxx> wrote:
> > That's because when you use multios, the stdout (and other multios
> > descriptors) are not connected to a real terminal, but to a pipe
> > connected to the invoking zsh process, zsh then sends the output to
> > multiple files or devices.
> > Because scrapy is not connected to a real terminal, it behaves
> > differently.
>
> I wonder if it's not fully on scrappy's side, i.e. that in such
> situation there are no actual obstacles in providing a working
> terminal-grasping app, which is rather proved by vim | cat working
> just normally. I.e. if it's scrapy that does a ttty-test (i.e. calls
> isatty()) and decides to provide a limited application. This is again
> fully proven by the fact that this command:
>
> vim > >(ansifilter > ansi.txt) > /dev/tty
>
> Works as expected – i.e. vim outputs a warning about output being not
> to a terminal, and then works without a single flaw, i.e. cursor-
> keys,
> home, end keys also working fine.
Try:
cat | vim > >(ansifilter > ansi.txt) > /dev/tty
Things don't work as well in this case.
> So could Zshell answer positively to the isatty() call, if at least
> one of the multios-outputs is a terminal? I think there's a big
> meaning, sense in this, however I don't want the email to be verbose.
No, because it's the command (and not the shell) that calls isatty() on
a random descriptor that should be connected to a terminal in the app's
opinion.
You could argue that in this case zsh should set-up a pseudo terminal
automatically, but:
* There are lot of extra semantics whose behavior is unclear in this
case. For example, terminal related signal and window sizing ioctls
have to be translated/forwarded between the top level terminal and
the emulated pty.
* Zsh has no way of knowing that a command will interact with the
terminal.
In short, it's not a good idea.
Have you investigated the script command? It may do what you need, and
it's standard.
Phil.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author