[olug] conditional $PATH

Tim & Alethea Larson thelarsons3 at cox.net
Thu Aug 4 20:28:30 UTC 2005


Vincent Raffensberger wrote:
> Something like this would do the job in ~/.*profile:
> 
> pathmunge () {
>         if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
>            if [ "$2" = "after" ] ; then
>               PATH=$PATH:$1
>            else
>               PATH=$1:$PATH
>            fi
>         fi
> }

I see what this is trying to do, but I don't follow how it actually does 
it.  I.e., where does "after" come from?

> if [ `id -g` = 1000 ]; then
>         pathmunge /some/path
>         pathmunge /some/other/path
> fi 

Cool, this is what I needed.  I will probably use the -Gn flag instead 
though.

Thanks,
Tim
-- 
Tim & Alethea
christtrek.org



More information about the OLUG mailing list