Fix shellcheck warnings
diff --git a/functions/common.sh b/functions/common.sh
index 9d0d956..29b3285 100644
--- a/functions/common.sh
+++ b/functions/common.sh
@@ -3,7 +3,7 @@
cleanup_and_exit()
{
trap EXIT
- exit ${1:-0}
+ exit "${1:-0}"
}
fail_exit()
@@ -20,19 +20,20 @@
eval "exec $fd>>$LOCKFILE"
case $1 in
"set")
- flock -x -n $fd \
+ flock -x -n "$fd" \
|| fail_exit "Process already running. Lockfile: $LOCKFILE"
;;
"unset")
- flock -u $fd
- rm -f $LOCKFILE
+ flock -u "$fd"
+ [ -f "$LOCKFILE" ] && rm -f "$LOCKFILE"
;;
"wait")
local TIMEOUT=${2:-3600}
- [ "${VERBOSE}" == "true" ] \
- && echo "Waiting of concurrent process (lockfile: $LOCKFILE, timeout = $TIMEOUT seconds) ..."
- flock -x -w $TIMEOUT $fd \
+ [ "$IS_VERBOSE" == "true" ] \
+ && echo "[INFO] Waiting of concurrent process (lockfile: $LOCKFILE, timeout = $TIMEOUT seconds) ..."
+ flock -x -w "$TIMEOUT" "$fd" \
|| fail_exit "Timeout error (lockfile: $LOCKFILE)"
+ [ "${IS_VERBOSE}" == "true" ] && echo "[INFO] Done"
;;
esac
}