X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=crontab.d%2Fupdate.sh;h=2b174c165a5437040044ff544b9034620e336dbd;hb=37ae4aa0eaf6b06546c0daa3e19ee4894ad01b3b;hp=72422fc90390e3c767eddfacd5fc676045eae484;hpb=19420fa802a6d29f6268221894798ba86938a15e;p=config%2Fdotfiles.git diff --git a/crontab.d/update.sh b/crontab.d/update.sh index 72422fc..2b174c1 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,12 @@ 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.