os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/installManPage
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 #    /^\\.SH NAME/{   ;# Look for a line, that starts with .SH NAME
    26 #	s/^.*$//      ;# Delete the content of this line from the buffer
    27 #	n             ;# Read next line
    28 #	s/,//g        ;# Remove all commas ...
    29 #	s/\\\ //g     ;# .. and backslash-escaped spaces.
    30 #	s/ \\\-.*//   ;# Delete from \- to the end of line
    31 #	p             ;# print the result
    32 #	q             ;# exit
    33 #   }
    34 #
    35 # Backslashes are trippled in the sed script, because it is in
    36 # backticks which don't pass backslashes literally.
    37 #
    38 # Please keep the commented version above updated if you
    39 # change anything to the script below.
    40 NAMES=`sed -n '
    41     /^\\.SH NAME/{
    42 	s/^.*$//
    43 	n
    44 	s/,//g
    45 	s/\\\ //g
    46 	s/ \\\-.*//
    47 	p
    48 	q
    49     }' $MANPAGE`
    50 
    51 SECTION=`echo $MANPAGE | sed 's/.*\(.\)$/\1/'`
    52 SRCDIR=`dirname $MANPAGE`
    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