Re: "at " doesn't work as documented
On Sat, 16 Feb 2019 01:48:11 +0100, Christian Weisgerber wrote: > I think tod() already has the required logic, but it doesn't handle > the case where the time is only past by minutes. Even better. OK millert@ - todd
Re: "at " doesn't work as documented
That looks like the correct fix. ok deraadt > > The manual is correct. Below is one way to fix this, though the > > logic probably belongs in tod() itself. > > I think tod() already has the required logic, but it doesn't handle > the case where the time is only past by minutes. > > Index: parsetime.c > === > RCS file: /cvs/src/usr.bin/at/parsetime.c,v > retrieving revision 1.26 > diff -u -p -r1.26 parsetime.c > --- parsetime.c 11 Nov 2015 17:42:51 - 1.26 > +++ parsetime.c 16 Feb 2019 00:44:27 - > @@ -432,7 +432,8 @@ tod(struct tm *tm) >* a relative offset, it's okay to bump things >*/ > if ((sc_tokid == EOF || sc_tokid == PLUS || sc_tokid == NEXT) && > - tm->tm_hour > hour) { > + (tm->tm_hour > hour || > + (tm->tm_hour == hour && tm->tm_min > minute))) { > tm->tm_mday++; > tm->tm_wday++; > } > -- > Christian "naddy" Weisgerber na...@mips.inka.de >
Re: "at " doesn't work as documented
Todd C. Miller: > The manual is correct. Below is one way to fix this, though the > logic probably belongs in tod() itself. I think tod() already has the required logic, but it doesn't handle the case where the time is only past by minutes. Index: parsetime.c === RCS file: /cvs/src/usr.bin/at/parsetime.c,v retrieving revision 1.26 diff -u -p -r1.26 parsetime.c --- parsetime.c 11 Nov 2015 17:42:51 - 1.26 +++ parsetime.c 16 Feb 2019 00:44:27 - @@ -432,7 +432,8 @@ tod(struct tm *tm) * a relative offset, it's okay to bump things */ if ((sc_tokid == EOF || sc_tokid == PLUS || sc_tokid == NEXT) && - tm->tm_hour > hour) { + (tm->tm_hour > hour || + (tm->tm_hour == hour && tm->tm_min > minute))) { tm->tm_mday++; tm->tm_wday++; } -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: "at " doesn't work as documented
On Fri, 15 Feb 2019 22:36:08 +0100, Christian Weisgerber wrote: > The at(1) man page says: > at allows some moderately complex timespec specifications. It accepts > times of the form HHMM or HH:MM to run a job at a specific time of day. > (If that time is already past, the next day is assumed.) The manual is correct. Below is one way to fix this, though the logic probably belongs in tod() itself. - todd Index: usr.bin/at/parsetime.c === RCS file: /cvs/src/usr.bin/at/parsetime.c,v retrieving revision 1.26 diff -u -p -u -r1.26 parsetime.c --- usr.bin/at/parsetime.c 11 Nov 2015 17:42:51 - 1.26 +++ usr.bin/at/parsetime.c 15 Feb 2019 22:16:36 - @@ -652,8 +652,22 @@ parsetime(int argc, char **argv) break; case NUMBER: - if (tod(&runtime) != 0 || month(&runtime) != 0) + if (tod(&runtime) != 0) return (-1); + + if (sc_tokid == EOF) { + /* If time in form HH:MM is past, assume tomorrow. */ + if (runtime.tm_mday == nowtime.tm_mday && + runtime.tm_wday == nowtime.tm_wday && + (runtime.tm_hour < nowtime.tm_hour || + (runtime.tm_hour == nowtime.tm_hour && + runtime.tm_min < nowtime.tm_min))) { + runtime.tm_mday++; + runtime.tm_wday++; + } + } else if (month(&runtime) != 0) { + return (-1); + } break; /*
"at " doesn't work as documented
OpenBSD 6.4-current (GENERIC.MP) #2: Thu Feb 14 21:19:17 CET 2019 na...@ariolc.mips.inka.de:/sys/arch/amd64/compile/GENERIC.MP The at(1) man page says: at allows some moderately complex timespec specifications. It accepts times of the form HHMM or HH:MM to run a job at a specific time of day. (If that time is already past, the next day is assumed.) However: $ date Fri Feb 15 22:32:41 CET 2019 $ at 22:00 at: cannot schedule jobs in the past Rather than assuming the next day, at(1) refuses the job. I don't know if that is an implementation or documentation bug. -- Christian "naddy" Weisgerber na...@mips.inka.de