summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.sh106
1 files changed, 53 insertions, 53 deletions
diff --git a/src/main.sh b/src/main.sh
index 3aa9e08..0c4ca77 100644
--- a/src/main.sh
+++ b/src/main.sh
@@ -41,6 +41,59 @@ conf_key=
lock=
exit_status=
+_get_options()
+{
+ local opt=
+
+ unset OPTARG
+ while getopts "${OPTSTRING}" opt; do
+ if [ "x${opt}" != 'x?' ]; then
+ eval "opt_${opt}=\"\${OPTARG:-true}\""
+ fi
+ unset OPTARG
+ done
+
+ return 0
+}
+
+main()
+{
+ local cmd=
+ local status=
+
+ if [ -f "$(dirname -- "${0}")/.builddirstamp" ]; then
+ in_place=true
+ builddir="$(dirname -- "${0}")"
+ else
+ in_place=false
+ builddir=''
+ fi
+
+ load_locale
+
+ _get_options "${@}"
+ shift $((${OPTIND} - 1))
+
+ base_dir="${opt_b:-.}"
+
+ 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
+ cmd="${1}"
+ shift 1
+ fi
+
+ run_cmd "${cmd}" "${@}"
+ status=${?}
+
+ return ${status}
+}
+
_lock()
{
mkdir -p -- "${base_dir}/.db"
@@ -89,21 +142,6 @@ _init_sigs()
done
}
-_get_options()
-{
- local opt=
-
- unset OPTARG
- while getopts "${OPTSTRING}" opt; do
- if [ "x${opt}" != 'x?' ]; then
- eval "opt_${opt}=\"\${OPTARG:-true}\""
- fi
- unset OPTARG
- done
-
- return 0
-}
-
_get_conf()
{
local old_dir=
@@ -153,41 +191,3 @@ fini()
collect_garbage
_unlock
}
-
-main()
-{
- local cmd=
- local status=
-
- if [ -f "$(dirname -- "${0}")/.builddirstamp" ]; then
- in_place=true
- builddir="$(dirname -- "${0}")"
- else
- in_place=false
- builddir=''
- fi
-
- load_locale
-
- _get_options "${@}"
- shift $((${OPTIND} - 1))
-
- base_dir="${opt_b:-.}"
-
- 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
- cmd="${1}"
- shift 1
- fi
-
- run_cmd "${cmd}" "${@}"
- status=${?}
-
- return ${status}
-}