Lines 55-75
Link Here
|
55 |
rc-status --runlevel |
55 |
rc-status --runlevel |
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
_sanitize_path() |
|
|
59 |
{ |
60 |
local IFS=":" p= path= |
61 |
for p in $PATH; do |
62 |
case "$p" in |
63 |
/lib/rc/bin|/lib/rc/sbin);; |
64 |
/bin|/sbin|/usr/bin|/usr/sbin);; |
65 |
/usr/bin|/usr/sbin);; |
66 |
/usr/local/bin|/usr/local/sbin);; |
67 |
*) path="$path${path:+:}$p";; |
68 |
esac |
69 |
done |
70 |
echo "$path" |
71 |
} |
72 |
|
73 |
# Allow our scripts to support zsh |
58 |
# Allow our scripts to support zsh |
74 |
if [ -n "$ZSH_VERSION" ]; then |
59 |
if [ -n "$ZSH_VERSION" ]; then |
75 |
emulate sh |
60 |
emulate sh |
Lines 78-104
Link Here
|
78 |
setopt NO_GLOB_SUBST |
63 |
setopt NO_GLOB_SUBST |
79 |
fi |
64 |
fi |
80 |
|
65 |
|
81 |
# Make a sane PATH |
|
|
82 |
_PREFIX= |
83 |
_PKG_PREFIX=/usr |
84 |
_LOCAL_PREFIX=/usr/local |
85 |
_LOCAL_PREFIX=${_LOCAL_PREFIX:-/usr/local} |
86 |
_PATH=/lib/rc/bin |
87 |
case "$_PREFIX" in |
88 |
"$_PKG_PREFIX"|"$_LOCAL_PREFIX") ;; |
89 |
*) _PATH="$_PATH:$_PREFIX/bin:$_PREFIX/sbin";; |
90 |
esac |
91 |
_PATH="$_PATH":/bin:/sbin:/usr/bin:/usr/sbin |
92 |
|
66 |
|
93 |
if [ -n "$_PKG_PREFIX" ]; then |
67 |
# Make a sane PATH. We begin with a standard, fixed value that is suitable for |
94 |
_PATH="$_PATH:$_PKG_PREFIX/bin:$_PKG_PREFIX/sbin" |
68 |
# a system manager. Next, /lib/rc/bin is prepended and any paths defined by the |
95 |
fi |
69 |
# existing value of PATH are appended, provided they are deemed safe and do not |
96 |
if [ -n "$_LOCAL_PREFIX" ]; then |
70 |
# duplicate any of the standard paths. |
97 |
_PATH="$_PATH:$_LOCAL_PREFIX/bin:$_LOCAL_PREFIX/sbin" |
71 |
standard_path=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin |
98 |
fi |
72 |
standard_path=/lib/rc/bin:$standard_path |
99 |
_path="$(_sanitize_path "$PATH")" |
73 |
PATH=$standard_path$( |
100 |
PATH="$_PATH${_path:+:}$_path" ; export PATH |
74 |
IFS=: |
101 |
unset _sanitize_path _PREFIX _PKG_PREFIX _LOCAL_PREFIX _PATH _path |
75 |
set -f |
|
|
76 |
for p in $PATH; do |
77 |
# Disregard empty and relative paths |
78 |
case $p in |
79 |
/*) ;; |
80 |
*) continue ;; |
81 |
esac |
82 |
# Ensure that it doesn't duplicate any of the standard paths |
83 |
case :$standard_path: in |
84 |
*:"$p":*) ;; |
85 |
*) printf %s ":$p" ;; |
86 |
esac |
87 |
done |
88 |
) |
89 |
unset standard_path |
102 |
|
90 |
|
103 |
for arg; do |
91 |
for arg; do |
104 |
case "$arg" in |
92 |
case "$arg" in |