This commit is contained in:
Valtteri Koskivuori 2025-07-11 12:48:10 -07:00 committed by GitHub
commit f3783d1b2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 15 deletions

21
deps/Makefile vendored
View File

@ -5,12 +5,21 @@ uname_S:= $(shell sh -c 'uname -s 2>/dev/null || echo not')
LUA_DEBUG?=no
LUA_COVERAGE?=no
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"
ifdef NO_COLOR
CCCOLOR=
LINKCOLOR=
SRCCOLOR=
BINCOLOR=
MAKECOLOR=
ENDCOLOR=
else
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"
endif
DEPS_CFLAGS := $(CFLAGS)
DEPS_LDFLAGS := $(LDFLAGS)

View File

@ -351,12 +351,21 @@ REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS)
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL)
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"
ifdef NO_COLOR
CCCOLOR=
LINKCOLOR=
SRCCOLOR=
BINCOLOR=
MAKECOLOR=
ENDCOLOR=
else
CCCOLOR="\033[34m"
LINKCOLOR="\033[34;1m"
SRCCOLOR="\033[33m"
BINCOLOR="\033[37;1m"
MAKECOLOR="\033[32;1m"
ENDCOLOR="\033[0m"
endif
ifndef V
QUIET_CC = @printf ' %b %b\n' $(CCCOLOR)CC$(ENDCOLOR) $(SRCCOLOR)$@$(ENDCOLOR) 1>&2;

View File

@ -1952,6 +1952,9 @@ int isPubsubPush(redisReply *r) {
int isColorTerm(void) {
char *t = getenv("TERM");
char *no_color = getenv("NO_COLOR");
if (no_color != NULL && no_color[0] != '\0')
return 0;
return t != NULL && strstr(t,"xterm") != NULL;
}
@ -10126,8 +10129,13 @@ static int displayKeyStatsProgressbar(unsigned long long sampled,
char red[] = "\033[31m";
char green[] = "\033[32m";
char default_color[] = "\033[39m";
snprintf(progressbar, sizeof(progressbar), "%s%s%s%s%s",
green, buf[0], red, buf[1], default_color);
if (isColorTerm()) {
snprintf(progressbar, sizeof(progressbar), "%s%s%s%s%s",
green, buf[0], red, buf[1], default_color);
} else {
snprintf(progressbar, sizeof(progressbar), "%s%s",
buf[0], buf[1]);
}
} else {
snprintf(progressbar, sizeof(progressbar), "%s", "keys scanned");
}

View File

@ -522,7 +522,7 @@ proc find_available_port {start count} {
# Test if TERM looks like to support colors
proc color_term {} {
expr {[info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]}
expr {![info exists ::env(NO_COLOR)] && [info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]}
}
proc colorstr {color str} {