Created attachment 372324 [details, diff] Proper colors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kirrun@kirNote ~ [1101]% gcc-config -l [1] x86_64-pc-linux-gnu-4.7.3 \033[32;01m*\033[0m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some tools (e.g. `gcc-config`) source functions.sh and then use variables defined there with `echo`. This doesn't work now, because they call echo without `-e`, so escape sequences are not interpreted. In the example above the offending lines are: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <...> x="${x} ${GOOD}*${NORMAL}" <...> echo " [${i}] ${x}" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I suggest using termcap for this, falling back to hardcoded escape sequences. That's what OpenRC does, as far as I can tell.
Perhaps we can fix the consumers to avoid adding deps.
This is, strictly speaking, bash's fault for not being POSIX-compliant. Solutions: - Fix the consumers to use echo -e or /bin/echo - Use the bashism $'' - Use tput Possibly more, but I think that's it.
(In reply to Alex Xu (Hello71) from comment #2) > This is, strictly speaking, bash's fault for not being POSIX-compliant. How is this related to POSIX compilance? POSIX: > If the first operand is -n, or if any of the operands contain a backslash ( '\' ) character, the results are implementation-defined. In my patch `tput` is not a strict dependency. But, well, you are right, _both_ using `tput` and fixing consumers might be a good idea.
(In reply to Kirill Elagin from comment #3) > (In reply to Alex Xu (Hello71) from comment #2) > > This is, strictly speaking, bash's fault for not being POSIX-compliant. > > How is this related to POSIX compilance? > > POSIX: > > If the first operand is -n, or if any of the operands contain a backslash ( '\' ) character, the results are implementation-defined. > I think this section has been amended. Another solution: use printf.
Created attachment 372384 [details, diff] gentoo-functions.patch Can you check this variation of the patch? I think we can do it this way and avoid a level of nesting. Thanks, William
(In reply to William Hubbs from comment #5) > Created attachment 372384 [details, diff] [details, diff] > gentoo-functions.patch > > Can you check this variation of the patch? > I think we can do it this way and avoid a level of nesting. > > Thanks, > > William Perhaps in the else use $(printf ...) to ensure that colors work on ANSI-compatible terminals. (although I'm not sure why you would really want colors if you're using dash and don't have ncurses)
(In reply to William Hubbs from comment #5) > Can you check this variation of the patch? Looks $GOOD ;).
Created attachment 372398 [details, diff] Fallback to printf As Alex suggested, falling back to `printf`.
FYI: this does work in dash.
This is fixed in 0.1. Thanks much to everyone involved.