Home > Software design >  Is there a syntax change in manpage for zsh vs bash?
Is there a syntax change in manpage for zsh vs bash?

Time:11-14

I've recently wrote a manpage, which display properly in bash shell. However, in zsh the man return an error message: /bin/zsh: can't open input file: man. Is there a difference in man syntax between zsh and bash? Below is an shorten example.

.\" Manpage for func.
.TH func 1 "08 Nov 2022" "1.0" "func man page"
.SH NAME
\fBfunc\fR - short desc.

.SH SYNOPSIS
\fBfunc\fR [\fB-h\fR] [\fB-D\fR \fIpath/to/destination\fR]

.SH DESCRIPTION
\fBiid_query.sh\fsome # more '\fIabc\fR'. other '\fI_abc\fR' continue name\*(lq\fI./abc\fR\*(rq.
.br
.B "    some    other"

.SH OPTIONS
\fB-D\fR \fIpath/to/destination\fR
.br
    The path of the destination directory.
.LP
\fB-h\fR
.br
    Display the usage.

.SH BUGS
No known bugs.

.SH AUTHOR
Someone

———————— Update ————————

The man page is stored within the project repo, the problem occurs when checking if the doc generated display properly. The repo tree is like below:

parent
|
 ———— src
|      |
|       —— func
|
 ———— man
       |
        —— func # manpage for func

The page is check by

man $ man ./func

In macOS 12 terminal (/bin/bash) and the ubuntu running as Win-subsystem (/bin/bash) the page can be display properly (tested on different machine). However, in macOS 13 terminal (/bin/zsh) the file cannot be opened by man. Current consideration is either macOS 13 contain a different version of man, or it is due to the change in zsh.

———————— Update ————————

$ mandoc -Tpdf "$(man -w ./func)"

produce properly formatted pdf.

Moreover, on the macOS 13 running zsh, man -V or man --version given an error. However, man for build-in command is working properly.

CodePudding user response:

After reading comments here and seeing this answer, I think the problem was not due to the difference between zsh and bash, but rather due to the removal of groff in the macOS 13, So I would need a alternative solution for inline-formatting my manpage or figure out why the following command would produce extra space around.

[
.B -abc
]

(gives following output with -abc being bolded)

[ -abc ]
  • Related