From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: multios stripping colors?
Date: Thu, 01 Feb 2018 07:52:21 -0800 [thread overview]
Message-ID: <5be03a10-ffcb-ef96-ed5a-46331d02762a@eastlink.ca> (raw)
In-Reply-To: <13088.1517470216@thecus.kiddle.eu>
On 31/01/18 11:30 PM, Oliver Kiddle wrote:
> Ray Andrews wrote:
>> $ eval "$@"
>>
>> That line in a function of mine can successfully eat some very complex
>> input including various pipes and color codes. However, when I try this:
> eval "eats" only shell syntax. Colour codes are eaten by your
> terminal. Perhaps you contrived to prevent them being generated or
> constructed something to filter them out.
Of course. Here's a current example:
_execute aptitude search \'$iinst ?description($1)\' '|'
egrep --color \'^\|$1\ $ggrep_oneline\'
'_execute' is a function that contains the above 'eval' plus a few other
things. As I run it with the line just above, I get 'aptitude' output
colored via egrep ....
>
>> $ eval "$@" >&2 >! /tmp/_output
>>
>> Although I do get both outputs, the screen looses all colorized output
... but again, if I do it this way the output to the screen goes B&W.
> There is nothing intrinsic to your construct that loses colour escape
> sequences. Try the following:
>
> eval "print -P '%K{blue}Hello'" >&2 >! /tmp/_output
> cat /tmp/_output
>
> This should give you a blue background from both commands.
Right, so it does.
>
> So you might need to take a closer look at exactly what argument you are
> passing to eval.
>
> Some commands, make coloured output conditional on whether their
> standard output points to a terminal. For an example, try:
> git log | cat
Maybe that's it. So is 'aptitude' or 'egrep' itself determining that
color is not to be had due to the double output? Sounds likely, I know
that the greps all behave differently when receiving piped input than
when not. And I'm correct that if one output is modified the other will
be too?
Thanks, I'll play with it a bit more.
=======================
>
> Oliver
>
next prev parent reply other threads:[~2018-02-01 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-01 5:11 Ray Andrews
2018-02-01 7:30 ` Oliver Kiddle
2018-02-01 15:52 ` Ray Andrews [this message]
2018-02-01 16:34 ` Ray Andrews
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=5be03a10-ffcb-ef96-ed5a-46331d02762a@eastlink.ca \
--to=rayandrews@eastlink.ca \
--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).