[olug] conditional $PATH

Jay Hannah jay at jays.net
Sat Aug 6 14:46:34 UTC 2005


On Aug 4, 2005, at 12:42 PM, 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
> }
>
> if [ `id -g` = 1000 ]; then
>         pathmunge /some/path
>         pathmunge /some/other/path
> fi

You don't have to export PATH?

j




More information about the OLUG mailing list