$PATH

Colin Watson cjwatson at canonical.com
Fri Dec 3 11:26:07 UTC 2004


On Fri, Dec 03, 2004 at 10:52:08AM +0900, janne wrote:
> The downside in general is that .bashrc is parsed every time you
> directly or indirectly open a new shell, so depending on your work
> habits, you may get the same path component several times in your PATH.
> Not critical for this particular case, but something to keep in mind for
> stuff you want to be done once and once only (or that are very slow).

prependpath () {
    [ -d "$1" ] || return
    case :$PATH: in
        *:"$1":*)
            ;;
        *)
            PATH="$1:$PATH"
            ;;
    esac
}

appendpath () {
    [ -d "$1" ] || return
    case :$PATH: in
        *:"$1":*)
            ;;
        *)
            PATH="$PATH:$1"
            ;;
    esac
}

prependpath "$HOME/bin"

-- 
Colin Watson                                    [cjwatson at canonical.com]




More information about the ubuntu-users mailing list