From 0f5dc89d0772eba2d1a06a57a7d3aeb69146a5a2 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 25 Apr 2019 20:58:13 -0400 Subject: _mutex_trylock(), mutex_is_unlockable(): Make "set -e"-safe --- diff --git a/src/mutex.sh b/src/mutex.sh index 4aa8e1f..be63d96 100644 --- a/src/mutex.sh +++ b/src/mutex.sh @@ -22,9 +22,8 @@ _mutex_trylock() { local mutex="${1}" - (set -C; printf '%d\n' "${$}" >"${mutex}") 2>/dev/null - - return ${?} + (set -C; printf '%d\n' "${$}" >"${mutex}") 2>/dev/null || return ${?} + return 0 } mutex_timedlock() @@ -52,7 +51,6 @@ mutex_is_unlockable() { local mutex="${1}" - [ "x$(cat "${mutex}" 2>/dev/null)" = "x${$}" ] - - return ${?} + [ "x$(cat "${mutex}" 2>/dev/null)" = "x${$}" ] || return ${?} + return 0 } -- cgit v0.9.1