From: Paul Hänsch Date: Sat, 13 Feb 2021 21:03:38 +0000 (+0100) Subject: use debug function for error output X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=8070ac946e7d593bd072567815c56cb1fdcb9bff;p=cgilite use debug function for error output --- diff --git a/storage.sh b/storage.sh index 7f70e64..f53fe7f 100755 --- a/storage.sh +++ b/storage.sh @@ -29,18 +29,18 @@ LOCK(){ lock="${1}.lock" timeout="${2-20}" if [ \! -w "${lock%/*}" ] || [ -e "$lock" -a \! -d "$lock" ]; then - printf 'Impossible to get lock: %s\n' "$lock" >&2 + debug "Impossible to get lock: $lock" return 1 fi while ! mkdir "$lock" 2>&-; do block="$(cat "$lock/pid" || printf 1)" if ! { ps -eo pid |grep -qwF "$block"; }; then - printf 'Overriding stale lock: %s\n' "$lock" >&2 + debug "Overriding stale lock: $lock" break fi if [ $timeout -le 0 ]; then - printf 'Timeout while trying to get lock: %s\n' "$lock" >&2 + debug "Timeout while trying to get lock: $lock" return 1 fi timeout=$((timeout - 1)) @@ -56,13 +56,13 @@ RELEASE(){ if [ "$(cat "$lock/pid")" = "$$" ]; then rm "$lock/pid" if ! rmdir "$lock"; then - printf 'Cannot remove tainted lock: %s\n' "$lock" >&2 + debug "Cannot remove tainted lock: $lock" printf '%i\n' $$ >"${lock}/pid" return 1 fi return 0 else - printf 'Refusing to release foreign lock: %s\n' "$lock" >&2 + debug "Refusing to release foreign lock: $lock" return 1 fi }