Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
When I do:
foo | bar
if foo
writes color encoded strings (with control chars) to stdout, they won't show up in bar - is there a way to get them to show up?
stdout stderr control-characters terminal-styling
 |Â
show 1 more comment
up vote
0
down vote
favorite
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
When I do:
foo | bar
if foo
writes color encoded strings (with control chars) to stdout, they won't show up in bar - is there a way to get them to show up?
stdout stderr control-characters terminal-styling
2
They do show up. You must be more specific, I suspect that you are talking about specific commands - for examplels
detects if it writes to terminal and only then highlights the output. Test for exampleecho -e 'abce[31mdefe[0mghi' | cat
.
â jimmij
Oct 14 '17 at 6:02
yeah when I am using a terminal, sometimes the colors still don't show up...?
â Alexander Mills
Oct 14 '17 at 6:24
1
Do you see red color with the command I gave or not?
â jimmij
Oct 14 '17 at 6:28
no I don't but I think that's a different issue
â Alexander Mills
Oct 14 '17 at 6:32
1
It turns out, from comments here and on Stack Overflow, that the real question was about a specific program that the questioner wrote whose message colourization library has a particular behaviour.
â JdeBP
Oct 14 '17 at 15:55
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
When I do:
foo | bar
if foo
writes color encoded strings (with control chars) to stdout, they won't show up in bar - is there a way to get them to show up?
stdout stderr control-characters terminal-styling
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
When I do:
foo | bar
if foo
writes color encoded strings (with control chars) to stdout, they won't show up in bar - is there a way to get them to show up?
stdout stderr control-characters terminal-styling
asked Oct 14 '17 at 5:50
Alexander Mills
1,9461029
1,9461029
2
They do show up. You must be more specific, I suspect that you are talking about specific commands - for examplels
detects if it writes to terminal and only then highlights the output. Test for exampleecho -e 'abce[31mdefe[0mghi' | cat
.
â jimmij
Oct 14 '17 at 6:02
yeah when I am using a terminal, sometimes the colors still don't show up...?
â Alexander Mills
Oct 14 '17 at 6:24
1
Do you see red color with the command I gave or not?
â jimmij
Oct 14 '17 at 6:28
no I don't but I think that's a different issue
â Alexander Mills
Oct 14 '17 at 6:32
1
It turns out, from comments here and on Stack Overflow, that the real question was about a specific program that the questioner wrote whose message colourization library has a particular behaviour.
â JdeBP
Oct 14 '17 at 15:55
 |Â
show 1 more comment
2
They do show up. You must be more specific, I suspect that you are talking about specific commands - for examplels
detects if it writes to terminal and only then highlights the output. Test for exampleecho -e 'abce[31mdefe[0mghi' | cat
.
â jimmij
Oct 14 '17 at 6:02
yeah when I am using a terminal, sometimes the colors still don't show up...?
â Alexander Mills
Oct 14 '17 at 6:24
1
Do you see red color with the command I gave or not?
â jimmij
Oct 14 '17 at 6:28
no I don't but I think that's a different issue
â Alexander Mills
Oct 14 '17 at 6:32
1
It turns out, from comments here and on Stack Overflow, that the real question was about a specific program that the questioner wrote whose message colourization library has a particular behaviour.
â JdeBP
Oct 14 '17 at 15:55
2
2
They do show up. You must be more specific, I suspect that you are talking about specific commands - for example
ls
detects if it writes to terminal and only then highlights the output. Test for example echo -e 'abce[31mdefe[0mghi' | cat
.â jimmij
Oct 14 '17 at 6:02
They do show up. You must be more specific, I suspect that you are talking about specific commands - for example
ls
detects if it writes to terminal and only then highlights the output. Test for example echo -e 'abce[31mdefe[0mghi' | cat
.â jimmij
Oct 14 '17 at 6:02
yeah when I am using a terminal, sometimes the colors still don't show up...?
â Alexander Mills
Oct 14 '17 at 6:24
yeah when I am using a terminal, sometimes the colors still don't show up...?
â Alexander Mills
Oct 14 '17 at 6:24
1
1
Do you see red color with the command I gave or not?
â jimmij
Oct 14 '17 at 6:28
Do you see red color with the command I gave or not?
â jimmij
Oct 14 '17 at 6:28
no I don't but I think that's a different issue
â Alexander Mills
Oct 14 '17 at 6:32
no I don't but I think that's a different issue
â Alexander Mills
Oct 14 '17 at 6:32
1
1
It turns out, from comments here and on Stack Overflow, that the real question was about a specific program that the questioner wrote whose message colourization library has a particular behaviour.
â JdeBP
Oct 14 '17 at 15:55
It turns out, from comments here and on Stack Overflow, that the real question was about a specific program that the questioner wrote whose message colourization library has a particular behaviour.
â JdeBP
Oct 14 '17 at 15:55
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
As commented by jimij, they do show up.
However, some programs (probably most programs outputting ANSI escape codes) are detecting that their output is not a tty by using isatty(3) e.g. as isatty(STDOUT_FILENO)
; and that is a good feature, because dealing with escapes in pipelines when you don't want them is a pain.
Several programs document a way to force that, e.g. ls(1) has --color=always
So read the documentation of the relevant commands.
yeah in my case, I control both foo and bar, and I want to figure out how to get the colors to show up
â Alexander Mills
Oct 14 '17 at 6:25
You read the documentation of bothfoo
andbar
.
â Basile Starynkevitch
Oct 14 '17 at 6:26
I think you misunderstood - I am authoring foo and bar
â Alexander Mills
Oct 14 '17 at 6:27
2
That should be a different question. Then show the code, perhaps as MCVE and ask it on StackOverflow.
â Basile Starynkevitch
Oct 14 '17 at 6:27
yeah maybe the package that I use to do the string styling will not do the styling if it's connected in a pipe? dunno
â Alexander Mills
Oct 14 '17 at 6:28
 |Â
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
As commented by jimij, they do show up.
However, some programs (probably most programs outputting ANSI escape codes) are detecting that their output is not a tty by using isatty(3) e.g. as isatty(STDOUT_FILENO)
; and that is a good feature, because dealing with escapes in pipelines when you don't want them is a pain.
Several programs document a way to force that, e.g. ls(1) has --color=always
So read the documentation of the relevant commands.
yeah in my case, I control both foo and bar, and I want to figure out how to get the colors to show up
â Alexander Mills
Oct 14 '17 at 6:25
You read the documentation of bothfoo
andbar
.
â Basile Starynkevitch
Oct 14 '17 at 6:26
I think you misunderstood - I am authoring foo and bar
â Alexander Mills
Oct 14 '17 at 6:27
2
That should be a different question. Then show the code, perhaps as MCVE and ask it on StackOverflow.
â Basile Starynkevitch
Oct 14 '17 at 6:27
yeah maybe the package that I use to do the string styling will not do the styling if it's connected in a pipe? dunno
â Alexander Mills
Oct 14 '17 at 6:28
 |Â
show 4 more comments
up vote
1
down vote
accepted
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
As commented by jimij, they do show up.
However, some programs (probably most programs outputting ANSI escape codes) are detecting that their output is not a tty by using isatty(3) e.g. as isatty(STDOUT_FILENO)
; and that is a good feature, because dealing with escapes in pipelines when you don't want them is a pain.
Several programs document a way to force that, e.g. ls(1) has --color=always
So read the documentation of the relevant commands.
yeah in my case, I control both foo and bar, and I want to figure out how to get the colors to show up
â Alexander Mills
Oct 14 '17 at 6:25
You read the documentation of bothfoo
andbar
.
â Basile Starynkevitch
Oct 14 '17 at 6:26
I think you misunderstood - I am authoring foo and bar
â Alexander Mills
Oct 14 '17 at 6:27
2
That should be a different question. Then show the code, perhaps as MCVE and ask it on StackOverflow.
â Basile Starynkevitch
Oct 14 '17 at 6:27
yeah maybe the package that I use to do the string styling will not do the styling if it's connected in a pipe? dunno
â Alexander Mills
Oct 14 '17 at 6:28
 |Â
show 4 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
As commented by jimij, they do show up.
However, some programs (probably most programs outputting ANSI escape codes) are detecting that their output is not a tty by using isatty(3) e.g. as isatty(STDOUT_FILENO)
; and that is a good feature, because dealing with escapes in pipelines when you don't want them is a pain.
Several programs document a way to force that, e.g. ls(1) has --color=always
So read the documentation of the relevant commands.
Why do colors not show up (control characters) when piping stdout/stderr on *nix systems?
As commented by jimij, they do show up.
However, some programs (probably most programs outputting ANSI escape codes) are detecting that their output is not a tty by using isatty(3) e.g. as isatty(STDOUT_FILENO)
; and that is a good feature, because dealing with escapes in pipelines when you don't want them is a pain.
Several programs document a way to force that, e.g. ls(1) has --color=always
So read the documentation of the relevant commands.
answered Oct 14 '17 at 6:21
Basile Starynkevitch
7,9231940
7,9231940
yeah in my case, I control both foo and bar, and I want to figure out how to get the colors to show up
â Alexander Mills
Oct 14 '17 at 6:25
You read the documentation of bothfoo
andbar
.
â Basile Starynkevitch
Oct 14 '17 at 6:26
I think you misunderstood - I am authoring foo and bar
â Alexander Mills
Oct 14 '17 at 6:27
2
That should be a different question. Then show the code, perhaps as MCVE and ask it on StackOverflow.
â Basile Starynkevitch
Oct 14 '17 at 6:27
yeah maybe the package that I use to do the string styling will not do the styling if it's connected in a pipe? dunno
â Alexander Mills
Oct 14 '17 at 6:28
 |Â
show 4 more comments
yeah in my case, I control both foo and bar, and I want to figure out how to get the colors to show up
â Alexander Mills
Oct 14 '17 at 6:25
You read the documentation of bothfoo
andbar
.
â Basile Starynkevitch
Oct 14 '17 at 6:26
I think you misunderstood - I am authoring foo and bar
â Alexander Mills
Oct 14 '17 at 6:27
2
That should be a different question. Then show the code, perhaps as MCVE and ask it on StackOverflow.
â Basile Starynkevitch
Oct 14 '17 at 6:27
yeah maybe the package that I use to do the string styling will not do the styling if it's connected in a pipe? dunno
â Alexander Mills
Oct 14 '17 at 6:28
yeah in my case, I control both foo and bar, and I want to figure out how to get the colors to show up
â Alexander Mills
Oct 14 '17 at 6:25
yeah in my case, I control both foo and bar, and I want to figure out how to get the colors to show up
â Alexander Mills
Oct 14 '17 at 6:25
You read the documentation of both
foo
and bar
.â Basile Starynkevitch
Oct 14 '17 at 6:26
You read the documentation of both
foo
and bar
.â Basile Starynkevitch
Oct 14 '17 at 6:26
I think you misunderstood - I am authoring foo and bar
â Alexander Mills
Oct 14 '17 at 6:27
I think you misunderstood - I am authoring foo and bar
â Alexander Mills
Oct 14 '17 at 6:27
2
2
That should be a different question. Then show the code, perhaps as MCVE and ask it on StackOverflow.
â Basile Starynkevitch
Oct 14 '17 at 6:27
That should be a different question. Then show the code, perhaps as MCVE and ask it on StackOverflow.
â Basile Starynkevitch
Oct 14 '17 at 6:27
yeah maybe the package that I use to do the string styling will not do the styling if it's connected in a pipe? dunno
â Alexander Mills
Oct 14 '17 at 6:28
yeah maybe the package that I use to do the string styling will not do the styling if it's connected in a pipe? dunno
â Alexander Mills
Oct 14 '17 at 6:28
 |Â
show 4 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398060%2fwhy-do-colors-not-show-up-control-characters-when-piping-stdout-stderr-on-nix%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
They do show up. You must be more specific, I suspect that you are talking about specific commands - for example
ls
detects if it writes to terminal and only then highlights the output. Test for exampleecho -e 'abce[31mdefe[0mghi' | cat
.â jimmij
Oct 14 '17 at 6:02
yeah when I am using a terminal, sometimes the colors still don't show up...?
â Alexander Mills
Oct 14 '17 at 6:24
1
Do you see red color with the command I gave or not?
â jimmij
Oct 14 '17 at 6:28
no I don't but I think that's a different issue
â Alexander Mills
Oct 14 '17 at 6:32
1
It turns out, from comments here and on Stack Overflow, that the real question was about a specific program that the questioner wrote whose message colourization library has a particular behaviour.
â JdeBP
Oct 14 '17 at 15:55