[devtools,3/4] lib/common.sh: lock, slock: Create directories for locks if necessary.

Message ID 20170325163441.28555-4-lukeshu@parabola.nu
State Accepted
Headers show
Series [devtools,1/4] lib/common.sh: add 'lock_close'; use it as appropriate. | expand

Commit Message

Luke Shumaker March 25, 2017, 4:34 p.m. UTC
---
 lib/common.sh | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/lib/common.sh b/lib/common.sh
index 63b7795..6d873ed 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -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