diff options
author | P. J. McDermott <pj@pehjota.net> | 2018-06-01 17:20:51 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2018-06-03 23:47:23 (EDT) |
commit | 4c56fae1cd594ea3d2070701b7795f5e95f6137f (patch) | |
tree | af0654b2d098ea14fca6ace3e3c547cdb5443d6f | |
parent | fa2f1a55f682cc3b39f493416770c1a581b7992a (diff) | |
download | homerc-4c56fae1cd594ea3d2070701b7795f5e95f6137f.zip homerc-4c56fae1cd594ea3d2070701b7795f5e95f6137f.tar.gz homerc-4c56fae1cd594ea3d2070701b7795f5e95f6137f.tar.bz2 |
bin/svc: Fix error handling
-rwxr-xr-x | bin/svc | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -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 |