]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
doc: help2man: support alternate format OSC hyperlinks
authorPádraig Brady <P@draigBrady.com>
Thu, 15 Jan 2026 21:36:09 +0000 (21:36 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 21 Jan 2026 13:51:39 +0000 (13:51 +0000)
* man/help2man: The BEL terminator format was already supported.
Add support for ESC + backslash terminator.  Also split out
and document the regular expression.

man/help2man

index 35ff3803eb4be5217d7c0fa825cdbb8f4b3f8912..75ef131077b54210a8df8a432896ebd6e27da065 100755 (executable)
@@ -815,11 +815,16 @@ sub get_option_value
 
     # Convert OSC 8 hyperlinks to markers placed after leading dashes
     # This preserves help2man's option detection (which looks for /^  +[-+]/)
-    $value =~ s/\x1b\]8;;([^\x07]*)\x07(--?)(.*?)\x1b\]8;;\x07/{
+    # 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
+        \x1b\]8;;(?:\x07|\x1b\\)                # closing OSC 8
+    /{
         my $idx = scalar @hyperlink_urls;
         push @hyperlink_urls, $1;
         "$2\x01$idx\x02$3\x03";
-    }/gse;
+    }/gsex;
 
     $value;
 }