diff --git a/crontab/crontab.go b/crontab/crontab.go index e55937d..a07eeee 100644 --- a/crontab/crontab.go +++ b/crontab/crontab.go @@ -85,7 +85,7 @@ func ParseCrontab(reader io.Reader) (*Crontab, error) { envVal := r[0][2] // Remove quotes (this emulates what Vixie cron does) - if envVal[0] == '"' || envVal[0] == '\'' { + if len(envVal) > 0 && (envVal[0] == '"' || envVal[0] == '\'') { if len(envVal) > 1 && envVal[0] == envVal[len(envVal)-1] { envVal = envVal[1 : len(envVal)-1] } diff --git a/crontab/crontab_test.go b/crontab/crontab_test.go index 995d7c7..df8a7b0 100644 --- a/crontab/crontab_test.go +++ b/crontab/crontab_test.go @@ -110,6 +110,18 @@ var parseCrontabTestCases = []struct { }, }, + { + "FOO=", + &Crontab{ + Context: &Context{ + Shell: "/bin/sh", + Environ: map[string]string{"FOO": ""}, + Timezone: time.Local, + }, + Jobs: []*Job{}, + }, + }, + { "CRON_TZ=UTC", &Crontab{