summaryrefslogtreecommitdiffstats
path: root/src/main.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.sh')
-rw-r--r--src/main.sh23
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()