summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pro-archman.sh42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/pro-archman.sh b/src/pro-archman.sh
index a174187..05b076f 100644
--- a/src/pro-archman.sh
+++ b/src/pro-archman.sh
@@ -33,8 +33,6 @@ OPTSTRING='hVb:'
# Global variables
loading_cmd=
-opt_base_dir=
-opt_cmd=
base_dir=
conf_incoming_channel=
conf_incoming_dir=
@@ -86,30 +84,32 @@ use garbage
main()
{
+ local cmd=
local status=
load_locale
load_cmds
- opt_cmd=''
-
get_options "${@}"
shift $(($OPTIND - 1))
- if [ ${#} -lt 1 ] && [ "x${opt_cmd}" = 'x' ]; then
- cmd_help_main >&2
- exit 1
- fi
- base_dir="${opt_base_dir:-.}"
+ base_dir="${opt_b:-.}"
- if [ "x${opt_cmd}" != 'x' ]; then
- run_cmd "${opt_cmd}" "${@}"
- status=${?}
+ if ${opt_h:-false}; then
+ cmd='help'
+ elif ${opt_V:-false}; then
+ cmd='version'
+ elif [ ${#} -lt 1 ]; then
+ cmd_help_main >&2
+ exit 1
else
- run_cmd "${@}"
- status=${?}
+ cmd="${1}"
+ shift
fi
+ run_cmd "${cmd}" "${@}"
+ status=${?}
+
return ${status}
}
@@ -117,18 +117,10 @@ get_options()
{
local opt=
+ unset OPTARG
while getopts "${OPTSTRING}" opt; do
- case "${opt}" in
- 'b')
- opt_base_dir="$(cd "${OPTARG}" && pwd)"
- ;;
- 'h')
- opt_cmd='help'
- ;;
- 'V')
- opt_cmd='version'
- ;;
- esac
+ eval "opt_${opt}=\"\${OPTARG:-true}\""
+ unset OPTARG
done
return 0