Skip to content
Snippets Groups Projects
Commit a5607365 authored by amd's avatar amd
Browse files

Make sure each file has a trailing newline.

parent d4cbe2ca
Branches
Tags
No related merge requests found
...@@ -1083,6 +1083,8 @@ def check_crontab(crontab_file, log, whitelisted_users=None): ...@@ -1083,6 +1083,8 @@ def check_crontab(crontab_file, log, whitelisted_users=None):
cron_line_factory = CronLineFactory() cron_line_factory = CronLineFactory()
with open(crontab_file, 'r') as crontab_f: with open(crontab_file, 'r') as crontab_f:
for line in crontab_f: for line in crontab_f:
missing_newline = line[-1] != "\n"
line = line.strip() line = line.strip()
line_no += 1 line_no += 1
...@@ -1091,5 +1093,9 @@ def check_crontab(crontab_file, log, whitelisted_users=None): ...@@ -1091,5 +1093,9 @@ def check_crontab(crontab_file, log, whitelisted_users=None):
log.Emit(line_no, line) log.Emit(line_no, line)
# are we missing a trailing newline?
if missing_newline:
log.Error('Cron will not process this file - missing trailing newline')
# Summarize the log messages if there were any. # Summarize the log messages if there were any.
return log.Summary() return log.Summary()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment