if [ "${NO_COLOR}" = "true" ] || [[ "${TERM:-}" != "xterm"* ]] || [ -t 1 ]; then
seems to be wrong really in at least 2 different ways.
1) It checks STDOUT to be connected to a terminal while logging happens on STDERR only.
2) It turns OFF colors if STDOUT is actually connected to a terminal.
I'm guessing here but a quick check seems to suggest that nobody noticed until now because __b3bp_log always got called in a subshell which actually was not connected to a terminal. If the function would be just called - as suggested by shellcheck - the code would not work as expected.
Now I can fix that, but before that I wanted to ask if there is something about this code, or the decisions leading to this code, which I overlooked or I don't understand.
https://github.com/kvz/bash3boilerplate/blob/9b739b4cf0c0c9f5454f7889e2417b258b1072dc/main.sh#L78
The line
seems to be wrong really in at least 2 different ways.
1) It checks STDOUT to be connected to a terminal while logging happens on STDERR only. 2) It turns OFF colors if STDOUT is actually connected to a terminal.
I'm guessing here but a quick check seems to suggest that nobody noticed until now because
__b3bp_log
always got called in a subshell which actually was not connected to a terminal. If the function would be just called - as suggested by shellcheck - the code would not work as expected.Now I can fix that, but before that I wanted to ask if there is something about this code, or the decisions leading to this code, which I overlooked or I don't understand.