]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
scripts/bash_aliases: pdfman(): Generalize the tool
authorAlejandro Colomar <alx.manpages@gmail.com>
Wed, 6 Oct 2021 14:15:41 +0000 (16:15 +0200)
committerAlejandro Colomar <alx.manpages@gmail.com>
Wed, 6 Oct 2021 14:15:43 +0000 (16:15 +0200)
Accept man(1) syntax, so that the function can open
system manual pages by [optional] section and page name.

As a side effect, this simplifies the invocation of man(1),
which didn't need '-l'.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
scripts/bash_aliases

index ecac0029de98f2465344be5f2e8d545dd398c393..be0672595a29a9eb9f61a74ff51fe1508846cc9f 100644 (file)
@@ -173,15 +173,14 @@ function man_lsvar()
 
 function pdfman()
 {
-       if (($# != 1)); then
-               >&2 echo "Usage: ${FUNCNAME[0]} <man-page.n>";
+       if (($# == 0)); then
+               >&2 echo "Usage: ${FUNCNAME[0]} [man(1) options] [section] page";
                return ${EX_USAGE};
        fi;
 
-       local tmp="$(mktemp -t "${1##*/}.XXXXXX")";
+       local tmp="$(mktemp -t "${!###*/}.XXXXXX")";
 
-       <${1} \
-       man -Tps -l - \
+       man -Tps $@ \
        |ps2pdf - - \
        >${tmp};
        xdg-open ${tmp};