]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
doc: use TERM=dumb rather than HELP_NO_MARKUP to disable markup
authorPádraig Brady <P@draigBrady.com>
Thu, 22 Jan 2026 11:42:47 +0000 (11:42 +0000)
committerPádraig Brady <P@draigBrady.com>
Thu, 22 Jan 2026 11:42:47 +0000 (11:42 +0000)
This is a more standard mechanism to disable markup.

* src/system.h (oputs_): Logic change to honor TERM=dumb,
rather than HELP_NO_MARKUP=something.
* doc/coreutils.texi: Adjust the description for --help.
* man/local.mk: Ensure TERM is set to something,
so that man pages have links included.
* man/viewman: Just honor users $TERM.
* tests/misc/getopt_vs_usage.sh: Remove env var complication,
as TERM is unset automatically.
* tests/misc/usage_vs_refs.sh: Likewise.
* NEWS: Adjust the change in behavior note.

NEWS
doc/coreutils.texi
man/local.mk
man/viewman
src/system.h
tests/misc/getopt_vs_usage.sh
tests/misc/usage_vs_refs.sh

diff --git a/NEWS b/NEWS
index e965e96ebdf28895d1ae2e04f70bc6e2bd6d672c..41011b29966038e55337657e5a897b9edbeb016b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -70,7 +70,7 @@ GNU coreutils NEWS                                    -*- outline -*-
   with bold attributes, and hyperlinks into the online manual on gnu.org.
   The links can be configured with the --enable-manual-url configure option,
   and the bold highlighting with --disable-bold-man-page-references.
-  At runtime all markup can be disabled by setting the HELP_NO_MARKUP env var.
+  At runtime all markup can be disabled by with the TERM=dumb env var value.
 
   'fmt' -w,--width no longer includes '\n' in the width of a line.
   I.e., the specified width is interpreted to be an _inclusive_ maximum.
index 4a098e24ec4b5af51ddfc5c035cf332cd0f68da2..0d7757d144f28ee7a505f03d53dd522173813715 100644 (file)
@@ -764,12 +764,12 @@ these programs, abbreviations of the long options are not always recognized.
 
 @item --help
 @opindex --help
-@vindex HELP_NO_MARKUP
+@vindex TERM
 @cindex help, online
 Print a usage message listing all available options, then exit successfully.
 Help output may be marked up with terminal codes for formatting or
-hyperlinks, which can be disabled by setting the @env{HELP_NO_MARKUP}
-environment variable.
+hyperlinks, which can be disabled by unsetting the @env{TERM} environment
+variable, or setting it to the value @samp{dumb}.
 
 @item --version
 @opindex --version
index a34a4902c58dcc7e3209c7b7e8dae45b5ba94b5a..92cfebadd8caa0185511059ad2762d08ff05ef5a 100644 (file)
@@ -27,7 +27,8 @@ if HAVE_PERL
 if BOLD_MAN_REFS
 help2man_OPTS=--bold-refs
 endif
-run_help2man = $(PERL) -- $(srcdir)/man/help2man --loose-indent $(help2man_OPTS)
+run_help2man = env TERM=not_dumb $(PERL) -- \
+              $(srcdir)/man/help2man --loose-indent $(help2man_OPTS)
 else
 run_help2man = $(SHELL) $(srcdir)/man/dummy-man
 endif
index 7fb8fed9cbf932ecc946493211064b8b8b732137..ee9f313b9c9a17fdce01b3d7cb0db4da09e65e2d 100755 (executable)
@@ -8,7 +8,6 @@
 # export MANPAGER=less
 
 unset GROFF_NO_SGR
-unset HELP_NO_MARKUP
 
 hdir=$(dirname "$0")
 
index bf3ad620f3b3ab60bdc77bbdb4ff496248b5e8e7..c6fe16750e22bb04a5e080feb43977920d004d18 100644 (file)
@@ -542,7 +542,7 @@ is_nul (void const *buf, size_t length)
 /* Output --option descriptions;
    formatted with ANSI format and hyperlink codes.
    Any postprocessors like help2man etc. are expected to handle this,
-   though it can be disabled in edge cases with the HELP_NO_MARKUP env var.  */
+   though it can be disabled in edge cases with the TERM=dumb env var.  */
 
 #define oputs(option) oputs_ (PROGRAM_NAME, option)
 static inline void
@@ -554,13 +554,20 @@ oputs_ (MAYBE_UNUSED char const* program, char const *option)
 #else
     -1;  /* Lookup.  */
 #endif
-  if (help_no_sgr == 1
-      || (help_no_sgr == -1 && (help_no_sgr = !!getenv ("HELP_NO_MARKUP"))))
+  if (help_no_sgr == -1)
+    {
+      /* Note we don't consult isatty() since usually you
+         would want markup when piping to grep/less etc.  */
+      char const *term = getenv ("TERM");
+      help_no_sgr = (!term || !*term || streq (term, "dumb"));
+    }
+  if (help_no_sgr)
     {
       fputs (option, stdout);
       return;
     }
 
+
   char const* first_word = option + strspn (option, " \t\n");
   char const *option_text = strchr (option, '-');
   if (!option_text)
index 973ad06ae9d15f9334891d76e0de0815207aef6f..51b0324de6d2d0ad24329d2da9726a0920b23393 100755 (executable)
@@ -44,12 +44,12 @@ for prg in $built_programs; do
   got_option=false
   for opt in $(shortopts $sprg); do
     got_option=true
-    env HELP_NO_MARKUP=1 $prg --help | grep -F -- " -$opt" >/dev/null ||
+    env $prg --help | grep -F -- " -$opt" >/dev/null ||
       { printf -- '%s -%s missing from --help\n' $sprg $opt >&2; fail=1; }
   done
   for opt in $(longopts $sprg); do
     got_option=true
-    env HELP_NO_MARKUP=1 $prg --help | grep -F -- "--$opt" >/dev/null ||
+    env $prg --help | grep -F -- "--$opt" >/dev/null ||
       { printf -- '%s --%s missing from --help\n' $sprg $opt >&2; fail=1; }
   done
   test "$DEBUG" && test $got_option = false && echo No options for $prg ?
index 0e0d111fd7a7a62f52cbbfcb7fd1bdaa25c33181..ebb132a68ba545c026269e9460a34cc2478aee78 100755 (executable)
@@ -25,7 +25,7 @@ longopts() { getopts $1 | cut -s -d'"' -f2; }
 getopts() {
   skip='--help|--version'              # These refs treated specially
 
-  HELP_NO_MARKUP=1 env "$1" --help |
+  env "$1" --help |
   grep -E '^(  -|      --)' |          # find options
   grep -Ev -- " - |-M.*from first" |   # exclude invalid matches
   sed -e 's/^ *//' -e's/  .*//' |      # strip leading space and descriptions