[Techtalk] Help, I'm stumbling on the PATH
Malcolm Tredinnick
malcolm at commsecure.com.au
Mon Feb 24 14:11:14 EST 2003
On Sun, Feb 23, 2003 at 07:54:51PM -0500, Beth Johnson wrote:
> A little help needed here!
Other people have answered your specific question, but I thought I might
be able to help by explaining what the script does.
[...]
> # /etc/profile
>
> # System wide environment and startup programs, for login setup
> # Functions and aliases go in /etc/bashrc
>
> pathmunge () {
This is a function that is called later in the script to add things to
the PATH environment variable.
> if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
First it checks to see if the first argument to pathmunge() is already
in $PATH. If so, nothing happens, otherwise...
> if [ "$2" = "after" ] ; then
...if the second argument is "after"...
> PATH=$PATH:$1
add the first argument to the end of the $PATH variable.
> else
> PATH=$1:$PATH
Otherwise, add the first argument to the front of the $PATH variable.
> fi
> fi
> }
>
> # Path manipulation
> if [ `id -u` = 0 ]; then
> pathmunge /sbin
> pathmunge /usr/sbin
> pathmunge /usr/local/sbin
> fi
>
> pathmunge /usr/X11R6/bin after
For example, this adds /usr/X11R6/bin to the end of whatever $PATH is at
this point.
>
> unset pathmunge
This removes the pathmunge() function from your environment, since it
was only needed by this script.
> # No core files by default
> ulimit -S -c 0 > /dev/null 2>&1
>
> USER="`id -un`"
> LOGNAME=$USER
> MAIL="/var/spool/mail/$USER"
>
> HOSTNAME=`/bin/hostname`
> HISTSIZE=1000
>
> if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
> INPUTRC=/etc/inputrc
> fi
>
> export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
>
> for i in /etc/profile.d/*.sh ; do
> if [ -r "$i" ]; then
> . $i
> fi
> done
>
> unset i
Maybe this is useful for you, I don't know.
Cheers,
Malcolm
--
He who laughs last thinks slowest.
More information about the Techtalk
mailing list