zsh-users
 help / color / mirror / code / Atom feed
From: Philippe Troin <phil@fifi.org>
To: zsh-users@zsh.org
Subject: Re: Why multios affects >/dev/tty redirection?
Date: Thu, 07 Feb 2019 08:50:31 -0800	[thread overview]
Message-ID: <ffffd7a28793de6c2851628f8e95a62b957a0629.camel@fifi.org> (raw)
In-Reply-To: <CAKc7PVB6NZxTzUUnhMAjbZyuVaS6f7PGJReBPoHqQ4FR-k13wg@mail.gmail.com>

On Thu, 2019-02-07 at 14:00 +0100, Sebastian Gniazdowski wrote:
> On Tue, 5 Feb 2019 at 17:43, Philippe Troin <phil@fifi.org> 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.


      reply	other threads:[~2019-02-07 16:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-05  1:28 Sebastian Gniazdowski
2019-02-05 16:35 ` Philippe Troin
2019-02-07 13:00   ` Sebastian Gniazdowski
2019-02-07 16:50     ` Philippe Troin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ffffd7a28793de6c2851628f8e95a62b957a0629.camel@fifi.org \
    --to=phil@fifi.org \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).