2

I solved this once, but I cannot remember how I did!

In my child process, I have this:

echo -e "some control chars"

In my parent process, it will show the plain string, without any terminal styling. Isn't there some way to interpret the control chars coming from stdout/stderr of child processes in the parent?

To be specific I have this bash function sourced in the parent:

ql_cyan='\033[1;36m'
ql_no_color='\033[0m'

function ql_log_colors {
    echo "sourcing quicklock.sh"
    echo -e "${ql_cyan}sourcing quicklock.sh${ql_no_color}";
    echo "${ql_cyan}sourcing quicklock.sh${ql_no_color}";
}

export -f ql_log_colors

if I run ql_log_colors in the current shell, I get colors!

however, if I call ql_log_colors from a subshell, no colors will be displayed in the parent, just the plain string "sourcing quicklock.sh".

As you can see, I tried 3 variants of echo command, all just output plain text in the parent, if the echo statements are called from a child.

muru
  • 69,900
  • 13
  • 192
  • 292
Alexander Mills
  • 9,330
  • 19
  • 95
  • 180

0 Answers0