From 3c51bb8a4784849f037b6e0e06af45b84c2f6ab2 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 3 Apr 2007 16:18:13 +0000 Subject: [PATCH] quoting etc. --- crondiv | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crondiv b/crondiv index 666171c..1157511 100755 --- a/crondiv +++ b/crondiv @@ -3,26 +3,26 @@ # "Divide" a crontab frequency down by the first argument on the command line, # logging to the second argument, and executing the remainder. -if [ "X$1" = "X" -o "X$2" = "X" -o "X$3" = "X" ]; then +if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then echo "Usage: $0 frequency logfile command [ arguments ]" >&2 exit 1 fi -FREQUENCY=$1 -LOGFILE=$2 +FREQUENCY="$1" +LOGFILE="$2" shift 2 -if [ -f $LOGFILE ]; then - LASTEXEC=$(($(tail -n 1 $LOGFILE)+1)) +if [ -f "$LOGFILE" ]; then + LASTEXEC="$(($(tail -n 1 "$LOGFILE")+1))" else LASTEXEC=1 fi -if [ $LASTEXEC -ge $FREQUENCY ]; then - echo "$*" executed at $(date) >> $LOGFILE - echo 0 >> $LOGFILE +if [ "$LASTEXEC" -ge "$FREQUENCY" ]; then + echo "$* executed at $(date)" >> "$LOGFILE" + echo 0 >> "$LOGFILE" eval "$*" else - echo $LASTEXEC >> $LOGFILE + echo "$LASTEXEC" >> "$LOGFILE" fi -- 2.30.2