From 4e732b07153e50963c2ef16c38469a9e369d7a28 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 18 Nov 2013 13:13:18 +0100 Subject: [PATCH] crontab.d/update.sh: Minor cleanup. --- crontab.d/update.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crontab.d/update.sh b/crontab.d/update.sh index 72422fc..fd4a9ae 100755 --- a/crontab.d/update.sh +++ b/crontab.d/update.sh @@ -29,10 +29,10 @@ HEADER_WARNING="# WARNING! DO NOT EDIT THIS FILE! #" # Don't overwrite existing crontab entries. Not race condition free but that # can't be helped. if crontab -l >/dev/null 2>&1; then - if crontab -l | head -n3 | grep "^$HEADER_WARNING$" >/dev/null; then + if crontab -l | head -n3 | grep -F -x "$HEADER_WARNING" >/dev/null; then : else - echo "Existing crontab entry found, please remove it manually." + echo 'Existing crontab entry found, please remove it manually.' exit 2 fi fi @@ -46,10 +46,10 @@ fi # `set -e` aborts when `mktemp` fails. CRONTAB=`mktemp --tmpdir="$DIRECTORY" update-crontab.XXXXXXXXXXXX` -echo "###################################" > "$CRONTAB" -echo "$HEADER_WARNING" >> "$CRONTAB" -echo "###################################" >> "$CRONTAB" -echo >> "$CRONTAB" +echo '###################################' >"$CRONTAB" +echo "$HEADER_WARNING" >>"$CRONTAB" +echo '###################################' >>"$CRONTAB" +echo >>"$CRONTAB" printf "# It was generated from '%s/*' on %s." \ "$DIRECTORY" "`LANG=C date '+%a, %d %b %Y %H:%M:%S %z'`" >>"$CRONTAB" @@ -72,13 +72,13 @@ for file in "$DIRECTORY"/crontab.*; do # (cron doesn't expand variables). START_REGEX='^# This [a-zA-Z]* is free software: you can redistribute it' END_REGEX='^# along with this [a-zA-Z]*. If not, see <[^>]*>\.' - < "$file" sed -e "/$START_REGEX/,/$END_REGEX/ d" \ - -e "/^#[ ]*$/ d" \ - -e "/^# Copyright (C) [0-9][0-9]* / d" \ + <"$file" sed -e "/$START_REGEX/,/$END_REGEX/ d" \ + -e "/^#[ ]*$/ d" \ + -e "/^# Copyright (C) [0-9][0-9]* / d" \ | cat --squeeze-blank \ | sed "/^PATH/ s:\$HOME:$HOME:g" \ | sed 's/RAND_SLEEP \([0-9]*\)/sleep `perl -e "srand; print int rand \1;"`/' \ - >> "$CRONTAB" + >>"$CRONTAB" done # Update crontab with the crontab.* files. -- 2.45.2