#!/bin/sh # $Id$ # (c) 2000..2005, Christoph Berg # This program is free software covered by the GNU GPL. # cb 2005-05-24: use PREFIXES, general cleanup # This sh script uses lots of -d test to find all strange places where binaries # and other stuff are located. ~/.path-local can be used to add local prefixes # and single directories. # get canonized OS name [ -z "$OS" ] && . $HOME/bin/os > /dev/null # some defaults PREFIXES="$HOME:/usr/local:/usr/pkg:/usr::/usr/X11R6:/usr/openwin" # :: is /, /usr/pkg NetBSD, /usr/openwin Solaris PATH_PRELOAD="$HOME/bin/${OS:-/not/found/}" # my arch-dependent binaries PATH="$PATH:/usr/ucb:/usr/5bin:/usr/games" # some strange locations # in theory, manpath should make this script mostly redundant, but this does # not work for $HOME/man etc. if type manpath > /dev/null 2>&1 ; then save="$MANPATH" unset MANPATH MANPATH="$save:`manpath 2> /dev/null`" fi TMPDIRS="/tmp/$USER:$HOME/tmp" # where to find a better /tmp # file for local additions [ -f $HOME/.path-local ] && . $HOME/.path-local #echo PATH=$PATH #echo MANPATH=$MANPATH #echo INFOPATH=$INFOPATH IFS_SAVE=$IFS IFS=":" # returns true if the directory exists and is not yet in the first argument test_dir () { case :$1: in *:$2:*) return 1 ;; *) [ -d "$2" ] ; return $? ;; esac } save=$PATH PATH="" # cannot unset PATH on SunOS 4 for dir in $PATH_PRELOAD ; do test_dir "$PATH" "$dir" && PATH="$PATH${PATH:+:}$dir" done for dir in $PREFIXES ; do test_dir "$PATH" "$dir/bin" && PATH="$PATH${PATH:+:}$dir/bin" test_dir "$PATH" "$dir/sbin" && PATH="$PATH${PATH:+:}$dir/sbin" done for dir in $save ; do test_dir "$PATH" "$dir" && PATH="$PATH${PATH:+:}$dir" done unset PATH_PRELOAD export PATH save=$MANPATH unset MANPATH for dir in $PREFIXES ; do test_dir "$MANPATH" "$dir/share/man" && MANPATH="$MANPATH${MANPATH:+:}$dir/share/man" # test for /usr/man = /usr/share/man (BUG: fails for other symlinks) [ -h "$dir/man" ] && continue # -h, because -L fails on SunOS 4 test_dir "$MANPATH" "$dir/man" && MANPATH="$MANPATH${MANPATH:+:}$dir/man" done for dir in $save ; do [ -h "$dir" ] && continue test_dir "$MANPATH" "$dir" && MANPATH="$MANPATH${MANPATH:+:}$dir" done export MANPATH save=$INFOPATH unset INFOPATH for dir in $PREFIXES ; do test_dir "$INFOPATH" "$dir/share/info" && INFOPATH="$INFOPATH${INFOPATH:+:}$dir/share/info" test_dir "$INFOPATH" "$dir/info" && INFOPATH="$INFOPATH${INFOPATH:+:}$dir/info" done for dir in $save ; do test_dir "$INFOPATH" "$dir" && INFOPATH="$INFOPATH${INFOPATH:+:}$dir" done export INFOPATH # really ugly, broken workaround for SunOS 4 if [ -f /bin/test ] ; then TEST=/bin/test ; else TEST=test ; fi for dir in $TMPDIRS ; do if [ -d $dir ] && $TEST -O $dir ; then export TEMP=$dir TMP=$dir TMPDIR=$dir break fi done unset TMPDIRS TEST #unset TEXINPUTS #for dir in \ # $HOME/lib/latex $HOME/lib/latex/* # do case $dir in # *CVS) ;; # *) [ -d $dir ] && TEXINPUTS="${TEXINPUTS}:$dir" ;; # esac # $TEXINPUTS must start with ':' #done #export TEXINPUTS #if [ -f $HOME/lib/make/Makefile ] ; then # MAKEFILES=$HOME/lib/make/Makefile # export MAKEFILES #fi IFS=$IFS_SAVE unset test_dir dir save IFS_SAVE PREFIXES #echo PATH=$PATH #echo MANPATH=$MANPATH #echo INFOPATH=$INFOPATH