summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-10-12 15:55:39 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-10-12 15:55:39 (EDT)
commitaaa1103c66bd4a591ae765010deacb9d754fe782 (patch)
tree456c23f88d665428fd6a202919ce576023e040ba /src
parentf776f91033ff7bb4ecea0d10db5c920467d53458 (diff)
pro-archman: Factor out locking into lock().
Diffstat (limited to 'src')
-rw-r--r--src/pro-archman.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/pro-archman.sh b/src/pro-archman.sh
index 732db76..b1accae 100644
--- a/src/pro-archman.sh
+++ b/src/pro-archman.sh
@@ -104,11 +104,7 @@ main()
run_cmd "${opt_cmd}" "${@}"
status=${?}
else
- mkdir -p "${opt_base_dir}/.db"
- lock="${opt_base_dir}/.db/lock"
- if ! (set -C; printf '%d\n' "${$}" >"${lock}") 2>/dev/null; then
- error 2 "$(get_msg 'lock_fail')"
- fi
+ lock
get_conf
run_cmd "${@}"
status=${?}
@@ -139,6 +135,15 @@ get_options()
return 0
}
+lock()
+{
+ mkdir -p "${opt_base_dir}/.db"
+ lock="${opt_base_dir}/.db/lock"
+ if ! (set -C; printf '%d\n' "${$}" >"${lock}") 2>/dev/null; then
+ error 2 "$(get_msg 'lock_fail')"
+ fi
+}
+
get_conf()
{
local old_dir=