os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/installManPage
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/unix/installManPage Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,67 @@
1.4 +#!/bin/sh
1.5 +
1.6 +ZIP=:
1.7 +while true; do
1.8 + case $1 in
1.9 + -s | --symlinks ) S="-s ";;
1.10 + -z | --compress ) ZIP=$2; shift ;;
1.11 + -e | --extension ) Z=$2; shift ;;
1.12 + -s | --suffix ) SUFFIX=$2; shift ;;
1.13 + *) break ;;
1.14 + esac
1.15 + shift
1.16 +done
1.17 +if test "$#" != 2; then
1.18 + echo "Usage: installManPages <options> file dir"
1.19 + exit 1
1.20 +fi
1.21 +
1.22 +MANPAGE=$1
1.23 +DIR=$2
1.24 +test -z "$S" && S="$DIR/"
1.25 +
1.26 +# A sed script to parse the alternative names out of a man page.
1.27 +#
1.28 +# /^\\.SH NAME/{ ;# Look for a line, that starts with .SH NAME
1.29 +# s/^.*$// ;# Delete the content of this line from the buffer
1.30 +# n ;# Read next line
1.31 +# s/,//g ;# Remove all commas ...
1.32 +# s/\\\ //g ;# .. and backslash-escaped spaces.
1.33 +# s/ \\\-.*// ;# Delete from \- to the end of line
1.34 +# p ;# print the result
1.35 +# q ;# exit
1.36 +# }
1.37 +#
1.38 +# Backslashes are trippled in the sed script, because it is in
1.39 +# backticks which don't pass backslashes literally.
1.40 +#
1.41 +# Please keep the commented version above updated if you
1.42 +# change anything to the script below.
1.43 +NAMES=`sed -n '
1.44 + /^\\.SH NAME/{
1.45 + s/^.*$//
1.46 + n
1.47 + s/,//g
1.48 + s/\\\ //g
1.49 + s/ \\\-.*//
1.50 + p
1.51 + q
1.52 + }' $MANPAGE`
1.53 +
1.54 +SECTION=`echo $MANPAGE | sed 's/.*\(.\)$/\1/'`
1.55 +SRCDIR=`dirname $MANPAGE`
1.56 +FIRST=""
1.57 +for f in $NAMES; do
1.58 + f=$f.$SECTION$SUFFIX
1.59 + if test -z "$FIRST" ; then
1.60 + FIRST=$f
1.61 + rm -f $DIR/$FIRST $DIR/$FIRST.*
1.62 + sed -e "/man\.macros/r $SRCDIR/man.macros" -e "/man\.macros/d" \
1.63 + $MANPAGE > $DIR/$FIRST
1.64 + chmod 444 $DIR/$FIRST
1.65 + $ZIP $DIR/$FIRST
1.66 + else
1.67 + rm -f $DIR/$f $DIR/$f.*
1.68 + ln $S$FIRST$Z $DIR/$f$Z
1.69 + fi
1.70 +done