diff options
Diffstat (limited to 'rc.d')
-rwxr-xr-x | rc.d | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -42,19 +42,21 @@ case $1 in done ;; *) + # check min args count + (( $# < 2 )) && usage action=$1 shift # set same environment variables as init runlevel=$(/sbin/runlevel) - ENV="PATH='/bin:/usr/bin:/sbin:/usr/sbin'" - ENV+=" PREVLEVEL='${runlevel:0:1}'" - ENV+=" RUNLEVEL='${runlevel:2:1}'" - ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" - ENV+=" TERM='${TERM}'" + ENV=("PATH=/bin:/usr/bin:/sbin:/usr/sbin" + "PREVLEVEL=${runlevel%% *}" + "RUNLEVEL=${runlevel##* }" + "CONSOLE=${CONSOLE:-/dev/console}" + "TERM=$TERM") + cd / for i; do if [[ -x "/etc/rc.d/$i" ]]; then - cd / - eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" + /usr/bin/env -i "${ENV[@]}" "/etc/rc.d/$i" "$action" else printf "${C_OTHER}:: ${C_FAIL}Error: ${C_DONE}Daemon script $i does not exist.\n" fi |