zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Mark descriptor as terminal for the -t test
Date: Fri, 3 Jun 2016 18:30:29 +0200	[thread overview]
Message-ID: <CAKc7PVA9-ixBoCAwwSY9HFRdRoBJVDtNouB8cQGe6HtMmoHmQg@mail.gmail.com> (raw)
In-Reply-To: <160601214528.ZM14311@torch.brasslantern.com>

On 2 June 2016 at 06:45, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On May 13, 10:18am, Sebastian Gniazdowski wrote:
> } Subject: Mark descriptor as terminal for the -t test
> }
> } Having a descriptor X, pointing to a file or to a process (with >(cmd)
> } redirection), is it possible to make it look like terminal? For the
> } test -t to pass?
>
> No.  The "is a terminal" state is at the OS level; the descriptor must
> refer to a tty device file.

isatty() is a call that probably all programs use to test for the state

> } The goal is: make this more robust:
> }   exec > >(tee -a ~/$$.out)
> }
> } It works, catches output of commands, however e.g. from vim, message
> } about "output is not to a terminal" appears.
>
> Almost any interactive command will be confused or broken by that usage.
> This is the reason that e.g. the "script" command exists.

A robust program, the script. Recalls asciinema.

Turns out the commands are not so confused. Either they assume there
is no terminal, and strip terminal control codes from output, or
ignore the fact (e.g. vim) and work well.

> I presume this is related to your "ztrace" project.  I fear you're doomed
> to failure with that one, except in a very simple cases.

Turned out the isatty() == 0 is a useful thing. If a program is
capable of stripping his output out of control codes, let it do it. If
not, then it's a problem in general. So I was striving for a more
problematic situation. Could implement use of following program:

http://www.andre-simon.de/doku/ansifilter/en/ansifilter.php

to strip control codes, but have no motivation to do so. The dream of
"reuse output without mouse" is better to be implemented at terminal
level. Ctrl-Space to invoke sophisticated selection and completion
mechanism, to paste-in some part of what terminal has seen up to this
moment. iTerm2 folks did numerous of things in their v3 release, but
there is no reusing of output, no ztrace-like interface.

Best regards,
Sebastian Gniazdowski


  reply	other threads:[~2016-06-03 16:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13  8:18 Sebastian Gniazdowski
2016-06-02  4:45 ` Bart Schaefer
2016-06-03 16:30   ` Sebastian Gniazdowski [this message]
2016-06-03 18:33     ` Bart Schaefer

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=CAKc7PVA9-ixBoCAwwSY9HFRdRoBJVDtNouB8cQGe6HtMmoHmQg@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=schaefer@brasslantern.com \
    --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).