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: Tue, 05 Feb 2019 08:35:48 -0800	[thread overview]
Message-ID: <caa82dfcb041884c5bc07d40c50f28c365480587.camel@fifi.org> (raw)
In-Reply-To: <CAKc7PVB3RoqRXtZDpogiUOiYsS2ZZxRjy_5xk9gtYEKA1mDEyw@mail.gmail.com>

On Tue, 2019-02-05 at 02:28 +0100, Sebastian Gniazdowski wrote:
> Hello,
> I have a command:
> 
> scrapy crawl 2nd "$@" "${optarray[@]}" 2> /tmp/reply  2> /dev/tty 1>
> /tmp/reply 1> /dev/tty
> 
> When invoked this way, scrapy (a python project) spawns an
> interactive
> console and it isn't fully usable  – e.g.: cursor keys emit escape
> sequencess rather t than moving the cursor or browsing history.

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.

> However, when I invoke scrqpy in following way:
> 
> scrapy crawl 2nd "$@" "${optarray[@]}"  2> /dev/tty 1> /dev/tty

Here scappy is connected directly to the terminal, and everything works
as expected.

> Is there a way around this?

Not without the help of another tool that can emulate a terminal.
There was a very old tool called "pty" that could do that.
I wrote a long time ago an enhanced version of that tool called ptyopen
( http://ftp.fifi.org/phil/ptyopen/ ) that does the same thing.

You'd invoke it like:

   ptyopen scrapy crawl 2nd "$@" "${optarray[@]}" 2> /tmp/reply  2> /dev/tty 1> /tmp/reply 1> /dev/tty

It then creates a pseudo-terminal, launches scrapy in it, and the pty
output can then be used transparently with multios.

Phil.


  reply	other threads:[~2019-02-05 16:42 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 [this message]
2019-02-07 13:00   ` Sebastian Gniazdowski
2019-02-07 16:50     ` Philippe Troin

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=caa82dfcb041884c5bc07d40c50f28c365480587.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).