You can colour ttys by doing things like this
myscript.sh:
#!/bin/bash
echo -e "This is \033[0;31mRED\033[0m"
Often if another "parent" program runs myscript.sh
as a sub-process then the colour codes will get correctly passed back and the shell running the parent will show the colours of the child.
Often it doesn't work. GNU Make is a counter-example
Makefile:
foo:
./myscript.sh
If I run make foo
then the output is
This is \033[0;31mRED\033[0m
For some reason, make
feels the need to escape the output of child processes.
I find this surprising since whoever wrote make
would have had to add code, which is extra effort, to create an anti-feature. Or is it the case that applications such as make
throw a switch on the tty which makes everything get escaped automagically? If so can I override this behaviour and force programs such as make
to pass through child process data to the tty without transforming it? Or does each program control this behaviour its own way?
echo -e "This is \033[0;31mRED\033[0m"
in sh, the colours came out fine. – spraff Oct 16 '16 at 09:56