#!/bin/sh - # # @(#)$Id: INSTALL 544 2008-11-02 17:31:17Z jneitzel $ # # The author of this file, J.A. Neitzel , # hereby grants it to the public domain. # # # Install all of the osh and sh6 command files into the specified # directory. If any of sh6, glob6, if, goto, or fd2 cannot be found # by which(1), convert all of the sh6 command files to run with osh # instead. It is an error if osh cannot be found by which(1). # # If an error is detected, exit with an appropriate diagnostic and # a non-zero status. # # usage: ./INSTALL directory # umask 0022 PROGNAME="`basename $0`" if test X"$0" != X"INSTALL" -a X"$0" != X"./INSTALL" ; then echo "$PROGNAME: $0: Invalid INSTALL pathname." >&2 ; exit 1 fi if test $# -ne 1 -o X"$1" = X ; then echo "usage: $PROGNAME directory" >&2 ; exit 1 fi DIR="$1" case "$DIR" in tmp-$$) echo "$PROGNAME: $DIR: Reserved for internal use only." >&2 ; exit 1 ;; /|/etc*|/bin|/sbin|/usr/bin|/usr/sbin|/opt*|/var*) echo "$PROGNAME: $DIR: May result in a system conflict." >&2 echo "Try a subdirectory of /usr/local or $HOME instead." >&2 ; exit 1 ;; *) if test -d "$DIR" -a ! -w "$DIR" ; then echo "$PROGNAME: $DIR: Permission denied." >&2 ; exit 1 fi ;; esac if which . >/dev/null 2>&1 ; then echo "$PROGNAME: which: Invalid results." >&2 ; exit 1 fi if ! which osh >/dev/null 2>&1 ; then echo "$PROGNAME: osh: Not found." >&2 ; exit 1 fi test -d "$DIR" || mkdir -p "$DIR" test $? -eq 0 || exit 1 if ! which sh6 glob6 if goto fd2 >/dev/null 2>&1 ; then # Convert each sh6 command file to run with osh instead. for OLD in *.sh6 ; do NEW="${OLD%.sh6}.osh" if test ! -e "$NEW" ; then echo "Converting \`$OLD' to \`$NEW' ..." <"$OLD" sed 's/sh6/osh/g' >"$NEW" test $? -eq 0 || exit 1 NEWLIST="$NEWLIST $NEW" fi done mkdir tmp-$$ && mv *.sh6 tmp-$$/ || exit 1 ; echo fi # # Install everything now. # INSTALL="`which install`" MODE="-m 0555" for FILE in *.[os][sh][h6] ; do DEST="$DIR/${FILE%.*}" echo "$INSTALL -c $MODE $FILE $DEST" "$INSTALL" -c $MODE "$FILE" "$DEST" test $? -eq 0 || exit 1 if test X"$FILE" = X"lf.osh" ; then echo "ln -fs lf $DIR/li && ln -fs lf $DIR/ll" ln -fs lf "$DIR/li" && ln -fs lf "$DIR/ll" test $? -eq 0 || exit 1 fi done # # Clean up if needed. # if test X"$NEWLIST" != X -a -d tmp-$$ ; then rm -f $NEWLIST && mv tmp-$$/*.sh6 ./ && rmdir tmp-$$ fi # # Advise user if $PATH does not contain absolute pathname of $DIR. # cd "$DIR" case "$PATH" in *`pwd`*);; *) cat <&2 Prepend `pwd` to PATH in order to successfully invoke all of the command files. Appending `pwd` to PATH is another option but is less useful in the general case. EOI ;; esac