Skip to content

Empty manpage generated if help2man does not exist #58

@tomparkin

Description

@tomparkin

Due to the Makefile's use of a pipe to generate mons.1.gz, if help2man is not installed locally then the build apparently succeeds but generates an empty manpage:

$ rm mons.1.gz
$ make mons.1.gz
help2man -N -n "POSIX Shell script to quickly manage 2-monitors display." -h -h -v -v ./mons.sh | gzip - > mons.1.gz
/bin/sh: 1: help2man: not found
$ echo $?
0
$ ls -l mons.1.gz
-rw-rw-r-- 1 tom tom 20 Sep  4 15:08 mons.1.gz

I fixed this by adding a check for help2man:

diff --git a/Makefile b/Makefile
index b04ba89..69ad61f 100644
--- a/Makefile
+++ b/Makefile
@@ -27,11 +27,14 @@ install: $(LIB) $(MANPAGE)
        cp $(SCRIPT) $(BINDIR)/$(PKGNAME)
        sed -i -e "s#%LIBDIR%#$(LIBDIR)#" $(BINDIR)/$(PKGNAME)
 
-$(MANPAGE):
+check_help2man:
+       which help2man
+
+$(MANPAGE): check_help2man
        help2man -N -n "$(PKGDESC)" -h -h -v -v ./$(SCRIPT) | gzip - > $@
 
 uninstall:
        $(RM) -r $(LICENSEDIR) $(LIBDIR)
        $(RM) $(MANDIR)/$(MANPAGE) $(BINDIR)/$(PKGNAME)
 
-.PHONY: install uninstall
+.PHONY: install uninstall check_help2man

This then causes the build to fail in a more obvious fashion if help2man is not installed:

$ make mons.1.gz
which help2man
make: *** [Makefile:31: check_help2man] Error 1
$ ls mons.1.gz
ls: cannot access 'mons.1.gz': No such file or directory
$ sudo apt install help2man
$ make mons.1.gz
which help2man
/usr/bin/help2man
help2man -N -n "POSIX Shell script to quickly manage 2-monitors display." -h -h -v -v ./mons.sh | gzip - > mons.1.gz$ ls -l mons.1.gz
-rw-rw-r-- 1 tom tom 1148 Sep  4 15:13 mons.1.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions