# 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
# `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"
# (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.