Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2017-02-06 02:55:30 -0500
committerLuke Shumaker <lukeshu@parabola.nu>2017-02-06 03:10:11 -0500
commit09bc36a930319d1287c41b78b24acfb36b0a8715 (patch)
treeb5835925ca7e38c9810c26e02f0ec5b29bea41f5 /lib
parent76dec8507e2e767db07f967644ed8958f85cd5a2 (diff)
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).
Diffstat (limited to 'lib')
-rw-r--r--lib/common.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/common.sh b/lib/common.sh
index f6aea93..91a55dc 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -159,6 +159,14 @@ slock() {
}
##
+# usage : lock_close( $fd )
+##
+lock_close() {
+ local fd=$1
+ exec {fd}>&-
+}
+
+##
# usage: pkgver_equal( $pkgver1, $pkgver2 )
##
pkgver_equal() {