]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
doc: optimize logic to disable SGR output in --help
authorPádraig Brady <P@draigBrady.com>
Sat, 3 Jan 2026 17:15:12 +0000 (17:15 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 21 Jan 2026 13:51:39 +0000 (13:51 +0000)
* src/system.h (oputs_): Simplify processing if neither
MANUAL_URL or BOLD_MAN_REFS is defined.  Also ensure
we only lookup the HELP_NO_MARKUP env var once per process.

src/system.h

index 3c18641348e1b5e508ef24556f5adb14baebb390..e77a8fe9f9497dce1d5e8451a1a08f116f0221ce 100644 (file)
@@ -545,8 +545,14 @@ is_nul (void const *buf, size_t length)
 static inline void
 oputs_ (MAYBE_UNUSED char const* program, char const *option)
 {
-  static int help_no_sgr = -1;
-  if (help_no_sgr && (help_no_sgr = !!getenv ("HELP_NO_MARKUP")))
+  static int help_no_sgr =
+#if ! defined MANUAL_URL && ! defined BOLD_MAN_REFS
+    1;   /* Disable.  */
+#else
+    -1;  /* Lookup.  */
+#endif
+  if (help_no_sgr == 1
+      || (help_no_sgr == -1 && (help_no_sgr = !!getenv ("HELP_NO_MARKUP"))))
     {
       fputs (option, stdout);
       return;