A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
4 edited title
| link

Colored How does a program decide whether or not to have coloured output?

    Tweeted twitter.com/StackUnix/status/733561259187015681
3 edited tags
| link
2 edited body
source | link

When I execute a command from a terminal that prints coloured output (such as ls or gcc), the coloured output is printed. From my understanding, the process is actually outputting ANSI escape codes, and the terminal formats the colour.

However, if I execute the same command by another process (say a custom C application) and redirect the output to the application's own output, these colours do not persist.

How does a program decide weatherwhether or not to output text with colour format? Is there some environment variable?

When I execute a command from a terminal that prints coloured output (such as ls or gcc), the coloured output is printed. From my understanding, the process is actually outputting ANSI escape codes, and the terminal formats the colour.

However, if I execute the same command by another process (say a custom C application) and redirect the output to the application's own output, these colours do not persist.

How does a program decide weather or not to output text with colour format? Is there some environment variable?

When I execute a command from a terminal that prints coloured output (such as ls or gcc), the coloured output is printed. From my understanding, the process is actually outputting ANSI escape codes, and the terminal formats the colour.

However, if I execute the same command by another process (say a custom C application) and redirect the output to the application's own output, these colours do not persist.

How does a program decide whether or not to output text with colour format? Is there some environment variable?

1
source | link