From aaa1103c66bd4a591ae765010deacb9d754fe782 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 12 Oct 2013 15:55:39 -0400 Subject: pro-archman: Factor out locking into lock(). --- 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= -- cgit v0.9.1