Skip to content

Commit

Permalink
fix(colors): only print colors if NO_COLOR is non-empty string
Browse files Browse the repository at this point in the history
from <https://no-color.org/>:

> Command-line software which adds ANSI color to its output by default
> should check for a NO_COLOR environment variable that, when present
> and **not an empty string** (regardless of its value), prevents the
> addition of ANSI color.

(emphasis mine)

if NO_COLOR is an empty string, color should still be printed.
  • Loading branch information
pcrockett committed Jan 18, 2025
1 parent 4fa73db commit ec65bee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bashly/libraries/colors/colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
print_in_color() {
local color="$1"
shift
if [[ -z ${NO_COLOR+x} ]]; then
if [[ "${NO_COLOR:-}" == "" ]]; then
printf "$color%b\e[0m\n" "$*"
else
printf "%b\n" "$*"
Expand Down

0 comments on commit ec65bee

Please sign in to comment.