diff --git a/changelog.txt b/changelog.txt index 26b46fbe..8bd6c0f8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ jc changelog - Add crontab file parser with user support - Add __version__ variable to parser modules - Updated history parser to output "line" as an integer +- Bugfix in crontab file parser: header insertion was clobbering first row - Just-in-time loading of parser modules instead of loading all at start 20191217 v1.6.1 diff --git a/jc/parsers/crontab.py b/jc/parsers/crontab.py index b39a3b89..97d1e2e5 100644 --- a/jc/parsers/crontab.py +++ b/jc/parsers/crontab.py @@ -132,7 +132,7 @@ import jc.parsers.universal class info(): - version = '1.0' + version = '1.1' description = 'crontab file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -252,7 +252,7 @@ def parse(data, raw=False, quiet=False): 'command': cmd}) # Add header row for parsing - cleandata[0] = 'minute hour day_of_month month day_of_week command' + cleandata[:0] = ['minute hour day_of_month month day_of_week command'] if len(cleandata) > 1: cron_list = jc.parsers.universal.simple_table_parse(cleandata) diff --git a/jc/parsers/crontab_u.py b/jc/parsers/crontab_u.py index f5c83eff..41ad2b5f 100644 --- a/jc/parsers/crontab_u.py +++ b/jc/parsers/crontab_u.py @@ -254,7 +254,7 @@ def parse(data, raw=False, quiet=False): 'command': cmd}) # Add header row for parsing - cleandata[0] = 'minute hour day_of_month month day_of_week user command' + cleandata[:0] = ['minute hour day_of_month month day_of_week user command'] if len(cleandata) > 1: cron_list = jc.parsers.universal.simple_table_parse(cleandata) diff --git a/tests/fixtures/centos-7.7/crontab2.out b/tests/fixtures/centos-7.7/crontab2.out new file mode 100644 index 00000000..1ab8c175 --- /dev/null +++ b/tests/fixtures/centos-7.7/crontab2.out @@ -0,0 +1,5 @@ +# Run the hourly jobs +SHELL=/bin/bash +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=root +01 * * * * root run-parts /etc/cron.hourly