0

edit: I was in EternalTerminal session, and that was the source of the difference. In a regular ssh, it works.

I need to get commands in a pipe to believe they are in a PTY and emit colorized output.

script -c is known to be a workaround to do so.

But for me, ls --color=auto is colorized, and in script -q -e -c 'ls --color=auto' log; cat log nothing is colorized.

I do have LS_COLORS set.

The same happens with gcc: it's colorized in an interactive shell, but not in script -c.

How do programs in script -c find out that they are not in a tty? Why did it work before and doesn't now?

$ script -V
script from util-linux 2.33.2
$ ls --version
ls (GNU coreutils) 8.31
4
  • ls doesn't apply colours by default, IIRC. Is your ls an alias to ls --color? – muru Jun 10 '20 at 6:54
  • Right, thanks. It's ls --color=auto. Updating the question. BTW, I'm also in ssh. – Victor Sergienko Jun 10 '20 at 7:01
  • 1
    I can't repro - script -q -e -c 'ls --color' /tmp/log shows colours (SSH to a Arch Linux system from a macOS iTerm): i.stack.imgur.com/iFyJX.jpg – muru Jun 10 '20 at 7:11
  • Yep. I also find that script -q -e -c 'ls --color' /tmp/log gives colours on Cygwin, Raspbian 10, Debian 10, and CentOS 7 – roaima Jun 10 '20 at 8:45
0

After describing my environment in more detail, I found that the suspect that makes the difference is Eternal Terminal.

I've submitted an issue, in case if it's a problem and not an intended behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.