diff options
author | Roy Marples <roy@marples.name> | 2008-03-19 15:21:42 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-03-19 15:21:42 +0000 |
commit | 0e6eb0f7640a5994755e93ea65e630d6ab917eaa (patch) | |
tree | 91991831fc07da7d1c936b4cb32390203301afbe /sh/functions.sh.in | |
parent | f69013adbe26b982bc1d0f49fd73e071ec85c79a (diff) |
Ensure that our path includes packages and local
Diffstat (limited to 'sh/functions.sh.in')
-rw-r--r-- | sh/functions.sh.in | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/sh/functions.sh.in b/sh/functions.sh.in index b8d3c95d..6cb482cc 100644 --- a/sh/functions.sh.in +++ b/sh/functions.sh.in @@ -43,7 +43,9 @@ _sanitize_path() local IFS=":" p= path= for p in ${PATH}; do case "${p}" in - @PREFIX@/lib/rc/sbin|@PREFIX@/bin|@PREFIX@/sbin|/usr/bin|/usr/sbin|@PKG_PREFIX@/bin|@PKG_PREFIX@/sbin);; + @PREFIX@/lib/rc/sbin|@PREFIX@/bin|@PREFIX@/sbin|/usr/bin|/usr/sbin);; + @PKG_PREFIX@/bin|@PKG_PREFIX@/sbin);; + @LOCAL_PREFIX@/bin|@LOCAL_PREFIX@/sbin);; *) path="${path}${path:+:}${p}";; esac done @@ -59,9 +61,23 @@ if [ -n "${ZSH_VERSION}" ]; then setopt NO_GLOB_SUBST fi -# Add our bin to $PATH -export PATH="@PREFIX@/lib/rc/bin:@PREFIX@/bin:@PREFIX@/sbin:/usr/bin:/usr/sbin:@PKG_PREFIX@/bin:@PKG_PREFIX@/sbin:$(_sanitize_path "${PATH}")" -unset _sanitize_path +# Make a sane PATH +_PKG_PREFIX=@PKG_PREFIX@ +_LOCAL_PREFIX=@LOCAL_PREFIX@ +_PATH=@PREFIX@/lib/rc/bin:@PREFIX@/bin:@PREFIX@/sbin +case "${_PREFIX}" in + ""|/) _PATH="${_PATH}:/usr/bin:/usr/sbin";; + /usr) _PATH="${_PATH}:/bin:/sbin";; + *) _PATH="${_PATH}:/bin:/sbin:/usr/bin:/usr/sbin";; +esac +if [ -n "${_PKG_PREFIX}" ]; then + _PATH="${_PATH}:${_PKG_PREFIX}/bin:${_PKG_PREFIX}/sbin" +fi +if [ -n "${_LOCAL_PREFIX}" ]; then + _PATH="${_PATH}:${_LOCAL_PREFIX}/bin:${_LOCAL_PREFIX}/sbin" +fi +export PATH="${_PATH}$(_sanitize_path "${PATH}")" +unset _sanitize_path _PKG_PREFIX _LOCAL_PREFIX _PATH for arg; do case "${arg}" in |