#! /bin/sh
# @(#)ADDKEYWORD version 3.3 created 2/12/96
# @(#)Copyright (c), 1987, 1996 StatSci, Inc.  All rights reserved.
#
usage="
`basename $0` keyword description...

This script adds a help file keyword description to the central keywords
file:

    $SHOME/splus/lib/X11/keywords

If the keyword is already present in the file, it is removed.

Its primary use is during the process of installing an S-PLUS add-on module.
"

if [ $# -le 1 ]
then
    echo "$usage" >&2
    exit 1
fi

tmpdir=${TMPDIR:-/tmp}
if [ ! -r $SHOME/splus/lib/X11/keywords.orig ]
then
    cp $SHOME/splus/lib/X11/keywords $SHOME/splus/lib/X11/keywords.orig ||
    (cp $SHOME/splus/lib/X11/keywords $tmpdir/keywords.$$
     echo >&2 "
Warning: couldn't backup original keywords file to

    $SHOME/splus/lib/X11/keywords.orig

Backing up original to $tmpdir/keywords.$$ instead.
"
    )
fi

tmpfile=$tmpdir/addkey.$$

keyword=$1; shift

sed < $SHOME/splus/lib/X11/keywords > $tmpfile  "/^$keyword	/d"
echo "$keyword	$*" >> $tmpfile
echo "Added: $keyword	$*"

cat $tmpfile > $SHOME/splus/lib/X11/keywords

rm -f $tmpfile
