[PATCH] ssh.1: balance square brackets in the synopsis

Arnout Engelen arnout at bzzt.net
Sun Oct 20 20:11:17 AEDT 2024


On Sun, Oct 20, 2024, at 00:12, Christian Weisgerber wrote:
> > I noticed the square brackets in `destination [command [argument...]`
> > were not balanced,
> 
> But they are.  Not only with mandoc(1), but also with groff(1).

Ah, indeed! Apparently the manpage is processed by mdoc2man.awk where the nesting is lost. This looks like it fixes it more neatly:

diff --git a/mdoc2man.awk b/mdoc2man.awk
index d393ae6f1..02a04f762 100644
--- a/mdoc2man.awk
+++ b/mdoc2man.awk
@@ -239,7 +239,7 @@ function add(str) {
       while(w<nwords&&match(words[w+1],"^[\\.,:;)]"))
        add(words[++w])
     } else if(match(words[w],"^Op$")) {
-      option=1
+      option++
       if(!nospace)
        nospace=1
       add("[")
@@ -358,7 +358,7 @@ function add(str) {
     add(")")
   if(angles)
     add(">")
-  if(option)
+  for(;option;option--)
     add("]")
   if(ext&&!extopt&&!match(line," $"))
     add(OFS)



More information about the openssh-unix-dev mailing list