]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
doc: help2man: convert all hyperlinks, not just ones in --options
authorPádraig Brady <P@draigBrady.com>
Thu, 15 Jan 2026 22:00:28 +0000 (22:00 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 21 Jan 2026 13:51:39 +0000 (13:51 +0000)
* man/help2man: Make the (--?) part of the match optional.
Note we still extract the dashes, to support the existing
option matching logic in help2man.

man/help2man

index 75ef131077b54210a8df8a432896ebd6e27da065..d778ac215953edb953e45f95ab2ced0361f64d01 100755 (executable)
@@ -765,7 +765,7 @@ for my $sect (@pre, (grep !$filter{$_}, @sections), @post)
            s/\x83/\\-/g;
 
            # Convert hyperlink markers to roff \X escape sequences
-           s{((?:\\f.)?\\-(?:\\-)?(?:\\f.)?)\x01(\d+)\x02(.*?)\x03}
+           s{((?:(?:\\f.)?\\-(?:\\-)?(?:\\f.)?)?)\x01(\d+)\x02(.*?)\x03}
             {convert_hyperlink($1, $2, $3)}gse;
 
            # Convert some latin1 chars to troff equivalents.
@@ -813,17 +813,18 @@ sub get_option_value
     # Strip ANSI SGR formatting codes (colors, bold, etc.)
     $value =~ s/\x1b\[[0-9;]*m//g;
 
-    # Convert OSC 8 hyperlinks to markers placed after leading dashes
+    # Convert OSC 8 hyperlinks to markers placed after any leading dashes
     # This preserves help2man's option detection (which looks for /^  +[-+]/)
     # Support both BEL (\x07) and ST (\x1b\) terminators
     $value =~ s/
         \x1b\]8;;([^\x07\x1b]*)(?:\x07|\x1b\\)  # opening OSC 8 with URL
-        (--?)(.*?)                              # dashes and link text
+        (--?)?(.*?)                             # optional dashes and link text
         \x1b\]8;;(?:\x07|\x1b\\)                # closing OSC 8
     /{
         my $idx = scalar @hyperlink_urls;
         push @hyperlink_urls, $1;
-        "$2\x01$idx\x02$3\x03";
+        my $dashes = $2 || "";
+        "$dashes\x01$idx\x02$3\x03";
     }/gsex;
 
     $value;