On 09/10/2026 08:52, Collin Funk wrote:
Eli Schwartz <[email protected]> writes:

to disable bold/underline/links in help text, but I think the underlying
principle is the same and I don't really know that I understand the
rationale for assuming by default that it will be read by less or, more
pertinently, that users have configured less to get output that doesn't
look like this:

I think the assumption was that people typically be outputting to a
terminal, even if the program was piped. E.g., the following:

     $ chroot --help | grep -F userspec

Would emit the option with the link included.

Also the more general point that one generally doesn't
want to programmatically process --help output,
apart from piping to a pager.

Yes, because of that and the other reports, I think something like this
is best:

diff --git a/src/system.h b/src/system.h
index 84be742ff..5646754b5 100644
--- a/src/system.h
+++ b/src/system.h
@@ -592,10 +592,11 @@ oputs_ (MAYBE_UNUSED char const *program, char const 
*option)
  #endif
    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"));
+      char const *term;
+      help_no_sgr = (isatty (STDOUT_FILENO)
+                     ? (!(term = getenv ("TERM")) || !*term
+                        || streq (term, "dumb"))
+                     : !getenv ("IN_HELP2MAN"));
      }
    if (help_no_sgr)
      {

But lets see what Pádraig thinks.
Ok fair enough. Let's be more conservative here.
Users won't get links if using a pager.

Leave it with me, and I'll come up with something along the lines of the above.

thanks,
Padraig



Reply via email to