Skip to content

Instantly share code, notes, and snippets.

@glennklockwood
Created July 23, 2015 01:56
Show Gist options
  • Save glennklockwood/95ff0137dcc6a2326e53 to your computer and use it in GitHub Desktop.
Save glennklockwood/95ff0137dcc6a2326e53 to your computer and use it in GitHub Desktop.
Script for setting up PATH on Solaris 10
# Built user paths in two parts
# Most important paths get prefixed in order of (least important) -> (most)
for dir in ~/bin
do
check=`expr "$PATH" : ".*:${dir}:.*" + \
"$PATH" : "${dir}:.*" + \
"$PATH" : ".*${dir}$"`
if [ $check = 0 ]
then
PATH=$dir:$PATH
fi
done
# sbin paths for root in order of (most important) -> (least)
if [ `/usr/xpg4/bin/id -u` -eq 0 ]; then
for dir in /usr/sbin /opt/csw/sbin
do
if [ -d $dir ]; then
check=`expr "$PATH" : ".*:${dir}:.*" + \
"$PATH" : "^${dir}:.*" + \
"$PATH" : ".*${dir}$"`
if [ $check = 0 ]
then
PATH=$PATH:$dir
fi
fi
done
fi
# Least important paths get suffixed in order of (most important) -> (least)
# Consider adding /usr/xpg4/bin and/or /usr/xpg6/bin before /usr/bin
for dir in /opt/sfw/bin /usr/bin /opt/csw/bin /opt/solstudio12.2/bin /usr/ccs/bin /usr/ucb /usr/sfw/bin
do
check=`expr "$PATH" : ".*:${dir}:.*" + \
"$PATH" : "${dir}:.*" + \
"$PATH" : ".*${dir}$"`
if [ $check = 0 ]
then
PATH=$PATH:$dir
fi
done
PATH=`echo $PATH | /usr/bin/tr -s ':'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment