summaryrefslogtreecommitdiffstats
path: root/tcl8.6/unix/installManPage
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2016-10-18 17:31:11 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2016-10-18 17:31:11 (GMT)
commit066971b1e6e77991d9161bb0216a63ba94ea04f9 (patch)
tree6de02f79b7a4bb08a329581aa67b444fb9001bfd /tcl8.6/unix/installManPage
parentba065c2de121da1c1dfddd0aa587d10e7e150f05 (diff)
parent9966985d896629eede849a84f18e406d1164a16c (diff)
downloadblt-066971b1e6e77991d9161bb0216a63ba94ea04f9.zip
blt-066971b1e6e77991d9161bb0216a63ba94ea04f9.tar.gz
blt-066971b1e6e77991d9161bb0216a63ba94ea04f9.tar.bz2
Merge commit '9966985d896629eede849a84f18e406d1164a16c' as 'tcl8.6'
Diffstat (limited to 'tcl8.6/unix/installManPage')
-rwxr-xr-xtcl8.6/unix/installManPage117
1 files changed, 117 insertions, 0 deletions
diff --git a/tcl8.6/unix/installManPage b/tcl8.6/unix/installManPage
new file mode 100755
index 0000000..1f1cbde
--- /dev/null
+++ b/tcl8.6/unix/installManPage
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+########################################################################
+### Parse Options
+###
+
+Gzip=:
+SymOrLoc=""
+Gz=""
+Suffix=""
+
+while true; do
+ case $1 in
+ -s | --symlinks ) SymOrLoc="-s " ;;
+ -z | --compress ) Gzip=$2; shift ;;
+ -e | --extension ) Gz=$2; shift ;;
+ -x | --suffix ) Suffix=$2; shift ;;
+ -*) cat <<EOF
+Unknown option "$1". Supported options:
+ -s Use symbolic links for manpages with multiple names.
+ -z PROG Use PROG to compress manual pages.
+ -e EXT Defines the extension added by -z PROG when compressing.
+ -x SUFF Defines an extra extension suffix to use.
+Option names may not be combined getopt-style.
+EOF
+ exit 1 ;;
+ *) break ;;
+ esac
+ shift
+done
+if test "$#" != 2; then
+ echo "Usage: installManPages <options> file dir"
+ exit 1
+fi
+
+########################################################################
+### Parse Required Arguments
+###
+
+ManPage=$1
+Dir=$2
+if test -f $ManPage ; then : ; else
+ echo "source manual page file must exist"
+ exit 1
+fi
+if test -d $Dir ; then : ; else
+ echo "target directory must exist"
+ exit 1
+fi
+test -z "$SymOrLoc" && SymOrLoc="$Dir/"
+
+########################################################################
+### Extract Target Names from Manual Page
+###
+
+# A sed script to parse the alternative names out of a man page.
+#
+# Backslashes are trippled in the sed script, because it is in
+# backticks which doesn't pass backslashes literally.
+#
+Names=`sed -n '
+# Look for a line that starts with .SH NAME
+ /^\.SH NAME/{
+# Read next line
+ n
+# Remove all commas ...
+ s/,//g
+# ... and backslash-escaped spaces.
+ s/\\\ //g
+# Delete from \- to the end of line
+ s/ \\\-.*//
+# Convert all non-space non-alphanum sequences
+# to single underscores.
+ s/[^ A-Za-z0-9][^ A-Za-z0-9]*/_/g
+# print the result and exit
+ p;q
+ }' $ManPage`
+
+if test -z "$Names" ; then
+ echo "warning: no target names found in $ManPage"
+fi
+
+########################################################################
+### Remaining Set Up
+###
+
+case $ManPage in
+ *.1) Section=1 ;;
+ *.3) Section=3 ;;
+ *.n) Section=n ;;
+ *) echo "unknown section for $ManPage"
+ exit 2 ;;
+esac
+
+SrcDir=`dirname $ManPage`
+
+########################################################################
+### Process Page to Create Target Pages
+###
+
+First=""
+for Target in $Names; do
+ Target=$Target.$Section$Suffix
+ rm -f $Dir/$Target $Dir/$Target.*
+ if test -z "$First" ; then
+ First=$Target
+ sed -e "/man\.macros/r $SrcDir/man.macros" -e "/man\.macros/d" \
+ $ManPage > $Dir/$First
+ chmod 644 $Dir/$First
+ $Gzip $Dir/$First
+ else
+ ln $SymOrLoc$First$Gz $Dir/$Target$Gz
+ fi
+done
+
+########################################################################
+exit 0