I tried to use git config --get-colorbool
to make my custom script emulate how normal Git commands decide when to color output.
However, unlike normal comands and contrary to what manual says, the command ignores whether stdout is TTY or not.
Additionally, it prints bools I pass to it, for some reason.
Here’s what I did:
git config --local color.ui always
git config --get-colorbool color.ui ; echo $?
git config --local color.ui never
git config --get-colorbool color.ui ; echo $?
git config --local color.ui auto
git config --get-colorbool color.ui ; echo $?
git config --get-colorbool color.ui 2>&1 | cat ; echo $?
git config --get-colorbool color.ui true ; echo $?
git config --get-colorbool color.ui false ; echo $?
The output is:
+ git config --local color.ui always
+ git config --get-colorbool color.ui
+ echo 0
0
+ git config --local color.ui never
+ git config --get-colorbool color.ui
+ echo 1
1
+ git config --local color.ui auto
+ git config --get-colorbool color.ui
+ echo 0
0
+ git config --get-colorbool color.ui
+ cat
+ echo 0
0
+ git config --get-colorbool color.ui true
true
+ echo 0
0
+ git config --get-colorbool color.ui false
false
+ echo 0
0
(My Git version is 2.34.1)
What am I doing wrong?