Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/unix/installManPage @ 25

Last change on this file since 25 was 25, checked in by landauf, 17 years ago

added tcl to libs

File size: 1.6 KB
Line 
1#!/bin/sh
2
3ZIP=:
4while 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
13done
14if test "$#" != 2; then
15    echo "Usage: installManPages <options> file dir"
16    exit 1
17fi
18
19MANPAGE=$1
20DIR=$2
21test -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#
28NAMES=`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
45case $MANPAGE in
46    *.1) SECTION=1 ;;
47    *.3) SECTION=3 ;;
48    *.n) SECTION=n ;;
49esac
50
51SRCDIR=`dirname $MANPAGE`
52
53FIRST=""
54for 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
67done
Note: See TracBrowser for help on using the repository browser.