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. 5 6set -e; set -u 7 8fatal_ () 9{ 10 printf '%s: %s\n' "$0" "$*" >&2 11 exit 1 12} 13 14basename_ () 15{ 16 printf '%s\n' "$1" | sed 's,.*/,,' 17} 18 19output= 20source="GNU coreutils" 21while 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 38done 39 40test $# -gt 0 || fatal_ "missing argument" 41test $# -le 1 || fatal_ "too many non-option arguments" 42 43dist_man=$(printf '%s\n' "$include" | sed 's/\.x$/.1/') 44test -f "$dist_man" && cp "$dist_man" "$output" && exit || : 45 46baseout=`basename_ "$output"` 47sed 's/^/WARNING: /' >&2 <<END 48Did not generate or find default '$baseout' man page. 49Creating a stub man page instead. 50END 51 52progname=`basename_ "$1"` 53bs='\' 54 55cat >"$output" <<END 56.TH "$progname" 1 "$source" "User Commands" 57.SH NAME 58$progname $bs- a $source program 59.SH DESCRIPTION 60.B OOPS! 61We were unable to create a proper manual page for 62.B $progname. 63For concise option descriptions, run 64.IP 65.B env $progname --help 66.PP 67The full documentation for 68.B $progname 69is maintained as a Texinfo manual, which should be accessible 70on your system via the command 71.IP 72.B info $bs(aq(coreutils) $progname invocation$bs(aq 73END 74