Skip to content

Commit b4fc2f9

Browse files
committed
fix % in crontab files not being properly escaped, since everything is run in a shell, normal % isn't going to work properly
1 parent e57609d commit b4fc2f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crontroll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ checkargs() {
6060
get_command() {
6161
lock="$lockdir/$1.lock"
6262
cron_command=$(cut -d" " -f6- < "$1")
63-
escaped_command=$(printf "%s" "$cron_command" | sed "s/'/'\\\\''/g")
63+
escaped_command=$(printf "%s" "$cron_command" | sed "s/'/'\\\\''/g; s/%/\\\\%/g")
6464
echo -n " sh -c '"
6565
echo -n "export CRONJOB=1;"
6666
echo -n "if ! kill -s 0 \`cat \"$lock\" 2>/dev/null\` 2>/dev/null; then "
6767
echo -n "echo \$\$ > \"$lock\" && "
6868
echo -n "(echo \"starting cronjob \$\$\";"
69-
echo -n "kill -s 0 \$\$;"
7069
echo -n "$escaped_command;"
7170
echo -n "echo cronjob finished;)"
7271
# Disable logger by creating a file called .NAME-nolog
@@ -124,6 +123,7 @@ list_crontab() {
124123
echo -en "$output\n\n"
125124
done
126125
fi
126+
echo crontab reloaded
127127
}
128128

129129
list() {
@@ -220,7 +220,7 @@ main() {
220220
printf "%s: %s; %s\n" "$status" "$f" "$cronjob"
221221
fi
222222
done
223-
if $reload;then
223+
if $reload; then
224224
reload_crontab
225225
fi
226226
if ! $donesomething; then

0 commit comments

Comments
 (0)