From 4c56fae1cd594ea3d2070701b7795f5e95f6137f Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 01 Jun 2018 17:20:51 -0400 Subject: bin/svc: Fix error handling --- diff --git a/bin/svc b/bin/svc index e97e915..9d65ac3 100755 --- a/bin/svc +++ b/bin/svc @@ -66,7 +66,6 @@ act() local action="${2}" shift 2 local out= - local es= log "${service}" "${action}" '' @@ -78,13 +77,12 @@ act() esac return 0 else - es=${?} log "${service}" "${action}" '_fail' case "${out}" in '') printf '\n';; *) printf '\n%s\n' "${out}";; esac - return ${es} + return 1 fi } @@ -129,14 +127,10 @@ chg_sessions() done if ${is_running} && ! ${should_run}; then - if ! act "${service}" 'stop'; then - return ${?} - fi + act "${service}" 'stop' || return 1 fi if ! ${is_running} && ${should_run}; then - if ! act "${service}" 'start'; then - return ${?} - fi + act "${service}" 'start' || return 1 fi return 0 @@ -164,16 +158,12 @@ main() case "${action}" in 'start' | 'stop' | 'restart' | 'status') load_service "${service}" || return 1 - if ! act "${service}" "${action}"; then - return ${?} - fi + act "${service}" "${action}" || return 1 ;; *';'*) load_service "${service}" || return 1 - if ! chg_sessions "${service}" \ - "${action%%;*}" "${action#*;}"; then - return ${?} - fi + chg_sessions "${service}" \ + "${action%%;*}" "${action#*;}" || return 1 ;; *) usage 1>&2 -- cgit v0.9.1