]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/colors: introduce color_get_disable_sequence()
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 15 Feb 2023 17:29:50 +0000 (17:29 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 15 Feb 2023 19:40:36 +0000 (19:40 +0000)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
include/colors.h
lib/colors.c

index d4ae4e407897cf4f77ad9647c3e6d6ad50922606..fe84d8bb906313f26cc371f1514f699f93d59cfb 100644 (file)
@@ -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 */
index c4bc08d0fccc430b0c84b054d5efb11789b8819a..5f35392b9d99db4fa3ede85f8f5a6d756850fe8b 100644 (file)
@@ -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_*
  */