#! /bin/sh # # Shell script to add stuff to user's path. It tries to find # /local/$1/bin, then /commercial/$1/bin, then the newest # /local/*/bin/$1, then the newest /commercial/*/bin/$1. # # Complaints to slumos@cs.unlv.edu oldpath=$PATH PATH=/bin:/usr/bin:/usr/ucb:/usr/bsd usage () { echo "usage: $0 " } if [ $# -ne "1" -o $1 = "-h" ]; then usage fi dir="" if [ -d "/local/$1/bin" ]; then dir="/local/$1/bin" elif [ -d "/commercial/$1/bin" ]; then dir="/commercial/$1/bin" else echo "Searching..." 1>&2 file=`ls -t /local/*/bin/$1 | head -1` if [ -f "${file}" ]; then echo "Found $1 as ${file}" 1>&2 dir=`dirname ${file}` else file=`ls -t /commercial/*/bin/$1 | head -1` if [ -f "${file}" ]; then echo "Found $1 as ${file}" 1>&2 dir=`dirname ${file}` fi fi fi mandir=`echo ${dir} | sed 's/bin$/man/g'` if (echo ${oldpath} | tr ':' '\012' | grep "^${dir}\$" >/dev/null 2>&1); then dir="" fi if [ x${dir} != x ]; then if [ x${SHELL} = "xcsh" ]; then echo "set path (${dir} ${path})" else echo "PATH=${dir}:\$PATH; export PATH" fi fi if (echo $MANPATH | tr ':' '\012' | grep "^${mandir}\$" >/dev/null 2>&1); then mandir="" fi if [ x${mandir} != x ]; then if [ x${SHELL} = "xcsh" ]; then [ -d ${mandir} ] && echo "setenv MANPATH ${mandir}:\$MANPATH" else [ -d ${mandir} ] && echo "MANPATH=${mandir}:\$MANPATH; export MANPATH" fi fi