maint: rename octhexdigits macros
[coreutils.git] / man / dummy-man
blobe298295d022b060d9d81aff08f9d07a34fea89c9
1 #!/bin/sh
2 # Poor man's placeholder for help2man invocation on systems lacking perl,
3 # or when cross compiling.
4 # It just copies the distributed man pages.
6 set -e; set -u
8 fatal_ ()
10 printf '%s: %s\n' "$0" "$*" >&2
11 exit 1
14 basename_ ()
16 printf '%s\n' "$1" | sed 's,.*/,,'
19 output=
20 source="GNU coreutils"
21 while test $# -gt 0; do
22 case $1 in
23 # Help2man options we recognize and handle.
24 --output=*) output=`expr x"$1" : x'--output=\(.*\)'`;;
25 --output) shift; output=$1;;
26 --include=*) include=`expr x"$1" : x'--include=\(.*\)'`;;
27 --include) shift; include=$1;;
28 --source=*) source=`expr x"$1" : x'--source=\(.*\)'`;;
29 --source) shift; source=$1;;
30 # Recognize (as no-op) other help2man options that might be used
31 # in the makefile.
32 --info-page=*);;
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 dist_man=$(printf '%s\n' "$include" | sed 's/\.x$/.1/')
44 test -f "$dist_man" && cp "$dist_man" "$output" && exit || :
46 baseout=`basename_ "$output"`
47 sed 's/^/WARNING: /' >&2 <<END
48 Did not generate or find default '$baseout' man page.
49 Creating a stub man page instead.
50 END
52 progname=`basename_ "$1"`
53 bs='\'
55 cat >"$output" <<END
56 .TH "$progname" 1 "$source" "User Commands"
57 .SH NAME
58 $progname $bs- a $source program
59 .SH DESCRIPTION
60 .B OOPS!
61 We were unable to create a proper manual page for
62 .B $progname.
63 For concise option descriptions, run
64 .IP
65 .B env $progname --help
66 .PP
67 The full documentation for
68 .B $progname
69 is maintained as a Texinfo manual, which should be accessible
70 on your system via the command
71 .IP
72 .B info $bs(aq(coreutils) $progname invocation$bs(aq
73 END