Skip to content

Support backslash line continuation in crontabs - #246

Open
ChrisJr404 wants to merge 1 commit into
aptible:mainfrom
ChrisJr404:support-multiline-crontab-entries
Open

Support backslash line continuation in crontabs#246
ChrisJr404 wants to merge 1 commit into
aptible:mainfrom
ChrisJr404:support-multiline-crontab-entries

Conversation

@ChrisJr404

Copy link
Copy Markdown

Fixes #104.

This adds support for splitting a long crontab entry across several lines by ending a line with a backslash, like you can in a shell. The parser joins the continued lines back together before it works out the schedule and command, so this:

*/10 * * * * echo 'a' && \
             echo 'b' && \
             echo 'c'

now parses as a single job instead of being rejected.

A trailing backslash that is itself escaped (an even number of backslashes) does not continue the line, and the join happens after the comment check so a comment ending in a backslash can't swallow the job on the next line. I added test cases for the basic case, several continuations in a row, an env definition, the escaped-backslash case, and the comment guard, plus a short note in the README.

Happy to adjust the join behavior (for example trimming the leading whitespace on continued lines) if you would prefer something different.

A crontab entry can now span several physical lines by ending a line with
a backslash, the same way a shell continues a line. The parser joins those
lines back together before parsing the schedule and command.

Closes aptible#104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for multiline entries

1 participant