-1

I have a script with some 'USAGE' function. It echoes the params/args, etc. I know I can create a custom MAN page file, as of ex:

.TH man 8 "09 May 2021" "1.0" "myscript man page"
.SH NAME
myscript \- do some stuff
.SH SYNOPSIS
myscript [STUFF]
.SH DESCRIPTION
myscript is very useful and blah blah blah lorem ipsum lorem ipsum lazy dog jump over the brown fox.

and read it just fine, so it will be shown as a man page with

man ./man-file

Anyways, I want to embed this into the script; then show it as MAN formatted from there. I dont want to have an external file for it.

Simple part, is simple. Create a var within the script having above contents as MAN syntax. Now, how can I show it as MAN formatted?

Here are my tryings, nothing yielded any good result.

echo $man_text_var | man
man < <(echo $man_text_var)
echo $man_text_var | man /dev/stdin
man /dev/stdin <<EOF
   $man_text_var
EOF

is there a way to accomplish it? and yes, I did see the post Display man page from stdin - but it does not solve my problem. not using RST or POD.

  • So did you see that `| man -l -` in the duplicate? What do you think it does? Please do not delete questions and recreate them exactly the same... As said, for starters change `echo $man_text_var` to `echo "$man_text_va"` - it's one of the errors shellcheck.net will tell you about. Then pipe it to `man -l -`, as explained _in the duplicate_ `You can use the --local-file argument of the man command and specify - to read from stdin`, please _read_ https://stackoverflow.com/questions/27802024/display-man-page-from-stdin . – KamilCuk May 09 '21 at 22:00

1 Answers1

0

I was able to solve it with groff which is available on every distro.

echo "${x}" | groff -man -Tascii | less