~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to man/dummy-man

  • Committer: Colin Watson
  • Date: 2013-10-30 15:48:33 UTC
  • mfrom: (8.3.5 sid)
  • Revision ID: cjwatson@canonical.com-20131030154833-xdt6e1yfffqom1c4
merge from Debian 8.21-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
6
 
 
7
set -e; set -u
 
8
 
 
9
fatal_ ()
 
10
{
 
11
  printf '%s: %s\n' "$0" "$*" >&2
 
12
  exit 1
 
13
}
 
14
 
 
15
basename_ ()
 
16
{
 
17
  printf '%s\n' "$1" | sed 's,.*/,,'
 
18
}
 
19
 
 
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
 
39
 
 
40
test $# -gt 0 || fatal_ "missing argument"
 
41
test $# -le 1 || fatal_ "too many non-option arguments"
 
42
 
 
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
 
48
 
 
49
progname=`basename_ "$1"`
 
50
year=`LC_ALL=C date +%Y`
 
51
bs='\'
 
52
 
 
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