lib/common.sh: lock, slock: Create directories for locks if necessary.

This commit is contained in:
Luke Shumaker 2017-03-25 12:34:40 -04:00 committed by Jan Alexander Steffens (heftig)
parent d333440810
commit d4f09b2c7b
No known key found for this signature in database
GPG Key ID: A5E9288C4FA415FA
1 changed files with 2 additions and 0 deletions

View File

@ -140,6 +140,7 @@ get_full_version() {
lock() {
# Only reopen the FD if it wasn't handed to us
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
mkdir -p -- "$(dirname -- "$2")"
eval "exec $1>"'"$2"'
fi
@ -156,6 +157,7 @@ lock() {
slock() {
# Only reopen the FD if it wasn't handed to us
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
mkdir -p -- "$(dirname -- "$2")"
eval "exec $1>"'"$2"'
fi