maint: avoid a valgrind memory leak warning from pinky
[coreutils.git] / man / dummy-man
blob306937628d0119578854d1afb694e26f38284d54
1 #!/bin/sh
2 # Poor man's placeholder for help2man invocation on systems lacking perl;
3 # it generates a dummy man page stating that a proper one could not be
4 # generated, and redirecting the user back to either the info
5 # documentation or the '--help' output.
7 set -e; set -u
9 fatal_ ()
11 printf '%s: %s\n' "$0" "$*" >&2
12 exit 1
15 basename_ ()
17 printf '%s\n' "$1" | sed 's,.*/,,'
20 output=
21 source="GNU coreutils"
22 while test $# -gt 0; do
23 case $1 in
24 # Help2man options we recognize and handle.
25 --output=*) output=`expr x"$1" : x'--output=\(.*\)'`;;
26 --output) shift; output=$1;;
27 --source=*) source=`expr x"$1" : x'--source=\(.*\)'`;;
28 --source) shift; source=$1;;
29 # Recognize (as no-op) other help2man options that might be used
30 # in the makefile.
31 --include=*);;
32 --include) shift;;
33 -*) fatal_ "invalid or unrecognized help2man option '$1'";;
34 --) shift; break;;
35 *) break;;
36 esac
37 shift
38 done
40 test $# -gt 0 || fatal_ "missing argument"
41 test $# -le 1 || fatal_ "too many non-option arguments"
43 baseout=`basename_ "$output"`
44 sed 's/^/WARNING: /' >&2 <<END
45 Cannot create proper '$baseout' man page, since perl is missing or
46 inadequate on this system. Creating a stub man page instead.
47 END
49 progname=`basename_ "$1"`
50 year=`LC_ALL=C date +%Y`
51 bs='\'
53 cat >"$output" <<END
54 .TH "$progname" 1 "$year" "$source" "User Commands"
55 .SH NAME
56 $progname $bs- a $source program
57 .SH DESCRIPTION
58 .B OOOPS!
59 Due to the lack of perl on the build system, we were
60 unable to create a proper manual page for
61 .B $progname.
62 For concise option descriptions, run
63 .IP
64 .B env $progname --help
65 .PP
66 The full documentation for
67 .B $progname
68 is maintained as a Texinfo manual, which should be accessible
69 on your system via the command
70 .IP
71 .B info coreutils $bs(aq$progname invocation$bs(aq
72 END