Skip to content
Snippets Groups Projects
Unverified Commit 997bc1dc authored by Luke Shumaker's avatar Luke Shumaker Committed by Jan Alexander Steffens (heftig)
Browse files

lib/common.sh: add 'lock_close'; use it as appropriate.

`lock_close FD` is easier to remember than 'exec FD>&-`; and is especially
easier if FD is a variable (though that isn't actually taken advantage of
here).

This uses Bash 4.1+ `exec {var}>&-`, rather than the clunkier
`eval exec "$var>&-"` that was necessary in older versions of Bash.
Thanks to Dave Reisner for pointing this new bit of syntax out to me
the last time I submitted this (back in 2014, 4.1 had just come out).
parent f73c1f17
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then ...@@ -55,7 +55,7 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
subvolume_delete_recursive "${copy}" subvolume_delete_recursive "${copy}"
rm -rf --one-file-system "${copy}" rm -rf --one-file-system "${copy}"
done done
exec 9>&- lock_close 9
rm -rf --one-file-system "${chroots}/${repo}-${arch}" rm -rf --one-file-system "${chroots}/${repo}-${arch}"
mkdir -p "${chroots}/${repo}-${arch}" mkdir -p "${chroots}/${repo}-${arch}"
......
...@@ -158,6 +158,14 @@ slock() { ...@@ -158,6 +158,14 @@ slock() {
fi fi
} }
##
# usage : lock_close( $fd )
##
lock_close() {
local fd=$1
exec {fd}>&-
}
## ##
# usage: pkgver_equal( $pkgver1, $pkgver2 ) # usage: pkgver_equal( $pkgver1, $pkgver2 )
## ##
......
...@@ -108,7 +108,7 @@ create_chroot() { ...@@ -108,7 +108,7 @@ create_chroot() {
stat_done stat_done
# Drop the read lock again # Drop the read lock again
exec 8>&- lock_close 8
fi fi
# Update mtime # Update mtime
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment