Line | |
---|
1 | #!/bin/sh |
---|
2 | |
---|
3 | ZIP=: |
---|
4 | while true; do |
---|
5 | case $1 in |
---|
6 | -s | --symlinks ) S="-s ";; |
---|
7 | -z | --compress ) ZIP=$2; shift ;; |
---|
8 | -e | --extension ) Z=$2; shift ;; |
---|
9 | -s | --suffix ) SUFFIX=$2; shift ;; |
---|
10 | *) break ;; |
---|
11 | esac |
---|
12 | shift |
---|
13 | done |
---|
14 | if test "$#" != 2; then |
---|
15 | echo "Usage: installManPages <options> file dir" |
---|
16 | exit 1 |
---|
17 | fi |
---|
18 | |
---|
19 | MANPAGE=$1 |
---|
20 | DIR=$2 |
---|
21 | test -z "$S" && S="$DIR/" |
---|
22 | |
---|
23 | # A sed script to parse the alternative names out of a man page. |
---|
24 | # |
---|
25 | # Backslashes are trippled in the sed script, because it is in |
---|
26 | # backticks which doesn't pass backslashes literally. |
---|
27 | # |
---|
28 | NAMES=`sed -n ' |
---|
29 | # Look for a line, that starts with .SH NAME |
---|
30 | # optionally allow NAME to be surrounded |
---|
31 | # by quotes. |
---|
32 | /^\.SH NAME/{ |
---|
33 | # Read next line |
---|
34 | n |
---|
35 | # Remove all commas ... |
---|
36 | s/,//g |
---|
37 | # ... and backslash-escaped spaces. |
---|
38 | s/\\\ //g |
---|
39 | # Delete from \- to the end of line |
---|
40 | s/ \\\-.*// |
---|
41 | # print the result and exit |
---|
42 | p;q |
---|
43 | }' $MANPAGE` |
---|
44 | |
---|
45 | case $MANPAGE in |
---|
46 | *.1) SECTION=1 ;; |
---|
47 | *.3) SECTION=3 ;; |
---|
48 | *.n) SECTION=n ;; |
---|
49 | esac |
---|
50 | |
---|
51 | SRCDIR=`dirname $MANPAGE` |
---|
52 | |
---|
53 | FIRST="" |
---|
54 | for f in $NAMES; do |
---|
55 | f=$f.$SECTION$SUFFIX |
---|
56 | if test -z "$FIRST" ; then |
---|
57 | FIRST=$f |
---|
58 | rm -f $DIR/$FIRST $DIR/$FIRST.* |
---|
59 | sed -e "/man\.macros/r $SRCDIR/man.macros" -e "/man\.macros/d" \ |
---|
60 | $MANPAGE > $DIR/$FIRST |
---|
61 | chmod 444 $DIR/$FIRST |
---|
62 | $ZIP $DIR/$FIRST |
---|
63 | else |
---|
64 | rm -f $DIR/$f $DIR/$f.* |
---|
65 | ln $S$FIRST$Z $DIR/$f$Z |
---|
66 | fi |
---|
67 | done |
---|
Note: See
TracBrowser
for help on using the repository browser.