Skip to content

Commit 302eb8a

Browse files
committed
fix parsing ' in command
1 parent 698674f commit 302eb8a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

crontroll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ 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")
6364
echo -n " sh -c '"
6465
echo -n "export CRONJOB=1;"
6566
echo -n "if ! kill -s 0 \`cat \"$lock\" 2>/dev/null\` 2>/dev/null; then "
6667
echo -n "echo \$\$ > \"$lock\" && "
6768
echo -n "(echo \"starting cronjob \$\$\";"
6869
echo -n "kill -s 0 \$\$;"
69-
echo -n "$cron_command;"
70+
echo -n "$escaped_command;"
7071
echo -n "echo cronjob finished;)"
7172
# Disable logger by creating a file called .NAME-nolog
7273
if [ ! -f ."$1"-nolog ]; then

0 commit comments

Comments
 (0)