aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2014-04-08 11:37:27 -0400
committerCalvin Morrison <mutantturkey@gmail.com>2014-04-08 11:37:27 -0400
commitdc627016effd1bb247cef22932519ffb75bd520a (patch)
tree7a8cfcf14d3fcc26402247a4ffb51f2e33424db8
parent82864dce3b608537fe87ad518800699661b58985 (diff)
add messages, use directory instead of folder, check for regular file
-rwxr-xr-xlock12
1 files changed, 10 insertions, 2 deletions
diff --git a/lock b/lock
index b0ba75f..78e406a 100755
--- a/lock
+++ b/lock
@@ -1,6 +1,14 @@
lock() {
- if ! mkdir "$1" &>/dev/null; then
+ if [[ -f "$1" ]]; then
+ echo "$1 is not a lock directory."
+ exit 1
+ fi
+
+ if mkdir "$1" &>/dev/null; then
+ echo "lock $1 created" >&2
+ else
+ echo "lock $1 found, waiting for unlock" >&2
while true; do
sleep 2;
if [[ ! -d "$1" ]]; then
@@ -14,7 +22,7 @@ lock() {
if [[ "$#" -eq "1" ]]; then
lock $1
else
- echo "please supply one argument: the lock folder"
+ echo "please supply one argument: the lock directory."
exit 1
fi