Skip to content
Snippets Groups Projects
Commit 9cba8ec0 authored by Gregory Duchatelet's avatar Gregory Duchatelet
Browse files

Comments in variable assignment is not allowed

parent 4fd78db1
No related branches found
No related tags found
No related merge requests found
......@@ -681,6 +681,11 @@ class CronLineAssignment(object):
'Variable assignments in crontabs are not like shell.'
' $VAR is not expanded.')
if re.match('".+" ?#', self.variable) or re.match('[^"].*#', self.variable):
log.LineError(log.MSG_COMMENT,
'Variable assignments in crontabs are not like shell.'
' # comment is not allowed.')
class CronLineTimeAction(object):
"""Checks cron lines that specify a time and an action.
......@@ -881,7 +886,8 @@ class LogCounter(object):
'QUOTE_VALUES',
'SHELL_VAR',
'USER_NOT_FOUND',
'HOURS_NOT_MINUTES'))
'HOURS_NOT_MINUTES',
'COMMENT'))
def __init__(self):
"""Inits LogCounter."""
......
......@@ -24,6 +24,11 @@ OK_EMPTY=""
BAD_SPACE=
OK_SPACE=" "
# disable fail 1 for comment in variable assignment.
NO_COMMENT="something" # comment
NO_COMMENT=something # comment
NO_COMMENT="something # comment"
# disable warn 1 for bad time spec.
* 3 * * * root Warn for hours not minutes
# disable fail 1 for bad time spec.
......@@ -74,7 +79,7 @@ OK_SPACE=" "
1,4,6,*/5 */3,2,7 * * mOn-Fri root Good Day Range
1,4,6,*/5 */3,2,7 * * mOn-Fri/2 root Good Day Range Step
# chkcrontab: enable-msg=FIELD_VALUE_ERROR
# FAIL 1 for bad time spec.
# FAIL 3 for bad time spec.
1,4,6,*/5 */3,2,7 * * mOn/2 root Bad Day Step
1,4,6,*/5 */3,2,7 * * mOn-Fri/8 root Good Day Range Step
# disable warn 1 for probable missing user.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment