index : devtools32 | |
Archlinux32 fork of devtools | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/common.sh | 32 |
diff --git a/lib/common.sh b/lib/common.sh index b8bab9b..68b001d 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -162,19 +162,15 @@ get_full_version() { # usage : lock( $fd, $file, $message, [ $message_arguments... ] ) ## lock() { - local fd=$1 - local file=$2 - local mesg=("${@:3}") - # Only reopen the FD if it wasn't handed to us - if ! [[ "/dev/fd/$fd" -ef "$file" ]]; then - mkdir -p "${file%/*}" - eval "exec $fd>"'"$file"' + if ! [[ "/dev/fd/$1" -ef "$2" ]]; then + mkdir -p "${2%/*}" + eval "exec $1>"'"$2"' fi - if ! flock -n $fd; then - stat_busy "${mesg[@]}" - flock $fd + if ! flock -n $1; then + stat_busy "${@:3}" + flock $1 stat_done fi } @@ -183,19 +179,15 @@ lock() { # usage : slock( $fd, $file, $message, [ $message_arguments... ] ) ## slock() { - local fd=$1 - local file=$2 - local mesg=("${@:3}") - # Only reopen the FD if it wasn't handed to us - if ! [[ "/dev/fd/$fd" -ef "$file" ]]; then - mkdir -p "${file%/*}" - eval "exec $fd>"'"$file"' + if ! [[ "/dev/fd/$1" -ef "$2" ]]; then + mkdir -p "${2%/*}" + eval "exec $1>"'"$2"' fi - if ! flock -sn $fd; then - stat_busy "${mesg[@]}" - flock -s $fd + if ! flock -sn $1; then + stat_busy "${@:3}" + flock -s $1 stat_done fi } |