From: Thomas Weißschuh Date: Wed, 15 Feb 2023 17:29:50 +0000 (+0000) Subject: lib/colors: introduce color_get_disable_sequence() X-Git-Tag: v2.39-rc1~73^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f0175fe280bee86aa43cf4ca7bdfe6e9d0ec4816;p=thirdparty%2Futil-linux.git lib/colors: introduce color_get_disable_sequence() Signed-off-by: Thomas Weißschuh --- diff --git a/include/colors.h b/include/colors.h index d4ae4e4078..fe84d8bb90 100644 --- a/include/colors.h +++ b/include/colors.h @@ -70,4 +70,6 @@ static inline void color_disable(void) color_fdisable(stdout); } +const char *color_get_disable_sequence(void); + #endif /* UTIL_LINUX_COLORS_H */ diff --git a/lib/colors.c b/lib/colors.c index c4bc08d0fc..5f35392b9d 100644 --- a/lib/colors.c +++ b/lib/colors.c @@ -808,6 +808,17 @@ void color_fdisable(FILE *f) fputs(UL_COLOR_RESET, f); } +/* + * Get reset sequence + */ +const char *color_get_disable_sequence(void) +{ + if (!ul_colors.disabled && ul_colors.has_colors) + return UL_COLOR_RESET; + else + return ""; +} + /* * Parses @str to return UL_COLORMODE_* */