diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-01-17 16:10:31 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-01-17 16:10:31 (EST) |
commit | 09c583248e7c0aa5a833ec01262b8b4a7980234b (patch) | |
tree | e3ecd4028e888d6eb587d9703ace4d90396a624a /src/main.sh | |
parent | d5e46c35ea98e43b6ad380ac7fbc197b7881b220 (diff) | |
parent | e3ab87a78aafd979f6eb8bb75ef70304d87a1d6b (diff) |
Merge branch 'feature/improve-error-handling'
Diffstat (limited to 'src/main.sh')
-rw-r--r-- | src/main.sh | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main.sh b/src/main.sh index dae02d0..51b21ac 100644 --- a/src/main.sh +++ b/src/main.sh @@ -40,12 +40,13 @@ fi main() { local cmd= + local es= load_locale if ! get_options "${@}"; then cmd_help_main >&2 - exit 1 + return 1 fi shift $(($OPTIND - 1)) @@ -55,24 +56,34 @@ main() cmd='version' elif [ ${#} -lt 1 ]; then cmd_help_main >&2 - exit 1 + return 1 else cmd="${1}" shift fi srand $(expr ${$} + $(date '+%s')) - init_vardata + if ! init_vardata; then + return 2 + fi case "${cmd}" in 'help'|'version') ;; - *) check_uid || error 1 "$(get_msg 'uid_0_req')";; + *) + if ! check_uid; then + error "$(get_msg 'uid_0_req')" + return 1 + fi + ;; esac run_cmd "${cmd}" "${@}" + es=${?} - fini_vardata + if ! fini_vardata; then + return 2 + fi - return ${?} + return ${es} } check_uid() |