lock: check tools are executable

This commit is contained in:
Misty De Meo 2017-05-23 18:36:06 -07:00
parent 129ee966f8
commit 94ed3e3583
No known key found for this signature in database
GPG Key ID: 76CF846A2F674B2C

View File

@ -42,13 +42,13 @@ _create_lock() {
[[ -x "$ruby" ]] || ruby="$(which ruby 2>/dev/null)" [[ -x "$ruby" ]] || ruby="$(which ruby 2>/dev/null)"
[[ -x "$python" ]] || python="$(which python 2>/dev/null)" [[ -x "$python" ]] || python="$(which python 2>/dev/null)"
if [[ -n "$ruby" && $("$ruby" -e "puts RUBY_VERSION >= '1.8.7' ? 0 : 1") = 0 ]] if [[ -x "$ruby" && $("$ruby" -e "puts RUBY_VERSION >= '1.8.7' ? 0 : 1") = 0 ]]
then then
"$ruby" -e "File.new($lock_fd).flock(File::LOCK_EX | File::LOCK_NB) || exit(1)" "$ruby" -e "File.new($lock_fd).flock(File::LOCK_EX | File::LOCK_NB) || exit(1)"
elif [[ -n "$(which flock)" ]] elif [[ -x "$(which flock)" ]]
then then
flock -n "$lock_fd" flock -n "$lock_fd"
elif [[ -n "$python" ]] elif [[ -x "$python" ]]
then then
"$python" -c "import fcntl; fcntl.flock($lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)" "$python" -c "import fcntl; fcntl.flock($lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)"
else else