* Datecheck command (date comparison)
@ 2009-05-20 14:43 Chris Umphress
2009-05-20 15:35 ` Felix Zielcke
0 siblings, 1 reply; 5+ messages in thread
From: Chris Umphress @ 2009-05-20 14:43 UTC (permalink / raw)
To: GRUB Development
Hey,
I've written a command that allows you to take different actions based
on the day. Would anybody else find it useful? Here are some of my
tests from yesterday:
grub> if [ datecheck -gt 2009-3-20 = datecheck -lt 2009-06-21 ]; then echo; ech
o "It is spring!"; fi
It is spring!
error: unrecognized number
grub> if datecheck -gt 15; then echo "It is after the 15th of the month."; fi
It is after the 15th of the month.
grub> if datecheck -lt -w 2; then echo "It is before Tuesday."; fi
grub> if datecheck -eq -w 2; then echo "It is Tuesday."; fi
It is Tuesday.
grub> if datecheck 19; then echo "It is the 19th."; fi
It is the 19th.
grub> if datecheck -gt 05-10; then echo "It is after May 10th."; fi
It is after May 10th.
grub> if datecheck -w 0; then echo "It is Sunday."; fi
grub>
You might notice that there are two bugs associated with the first
test. It was an attempt to test two conditions at once, and without
being able to find any documentation (or anybody willing to answer
scripting questions), that is what I came up with. The "error:
unrecognized number" part may be due to this.
Because the command spanned two lines, an extra "echo" had to be added
so that the full command could be seen clearly. Without that, the
words would have overwritten the wrapped portion of the command.
The command is written in a lax manner that attempts to interpret
whatever it is given. You can do nonsensical things such as check if
today is before the 20th day of the week. It may be worth printing an
error message for that but I didn't think it necessary.
If anybody is interested, I have a patch for the SVN from a few days
ago (before the segfault on grub-install). Some of the changes since
then prevent it from being fully applied but the modifications
required would be minor.
--
Chris Umphress <http://www.epicvoyage.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Datecheck command (date comparison)
2009-05-20 14:43 Datecheck command (date comparison) Chris Umphress
@ 2009-05-20 15:35 ` Felix Zielcke
2009-05-20 21:36 ` Chris Umphress
0 siblings, 1 reply; 5+ messages in thread
From: Felix Zielcke @ 2009-05-20 15:35 UTC (permalink / raw)
To: The development of GRUB 2
Am Mittwoch, den 20.05.2009, 09:43 -0500 schrieb Chris Umphress:
> I've written a command that allows you to take different actions based
> on the day. Would anybody else find it useful? Here are some of my
> tests from yesterday:
Hello,
can't this just be done with the variables Bean introduced with his
datehook stuff[0]? $YEAR, $MONTH, $DAY, $HOUR, $MINUTE, $SECOND and
$WEEKDAY.
Though I never used this myself.
[0] http://lists.gnu.org/archive/html/grub-devel/2008-08/msg00274.html
--
Felix Zielcke
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Datecheck command (date comparison)
2009-05-20 15:35 ` Felix Zielcke
@ 2009-05-20 21:36 ` Chris Umphress
2009-05-21 3:01 ` Bean
0 siblings, 1 reply; 5+ messages in thread
From: Chris Umphress @ 2009-05-20 21:36 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, May 20, 2009 at 10:35 AM, Felix Zielcke <fzielcke@z-51.de> wrote:
> can't this just be done with the variables Bean introduced with his
> datehook stuff[0]? $YEAR, $MONTH, $DAY, $HOUR, $MINUTE, $SECOND and
> $WEEKDAY.
> Though I never used this myself.
>
> [0] http://lists.gnu.org/archive/html/grub-devel/2008-08/msg00274.html
Hmm, it would have been nice to know about this before. I haven't
succeeded in getting these variables to work so far today though. The
"set" command doesn't reflect that they exist, "echo $WEEKDAY" just
shows a blank line, and an if statement utilizing the variables always
returns "error: false"
Am I missing something?
--
Chris Umphress <http://www.epicvoyage.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Datecheck command (date comparison)
2009-05-20 21:36 ` Chris Umphress
@ 2009-05-21 3:01 ` Bean
2009-05-21 4:00 ` Chris Umphress
0 siblings, 1 reply; 5+ messages in thread
From: Bean @ 2009-05-21 3:01 UTC (permalink / raw)
To: The development of GRUB 2
Hi,
Have you forgotten "insmod datehook" ?
On Thu, May 21, 2009 at 5:36 AM, Chris Umphress <umphress@gmail.com> wrote:
> On Wed, May 20, 2009 at 10:35 AM, Felix Zielcke <fzielcke@z-51.de> wrote:
>> can't this just be done with the variables Bean introduced with his
>> datehook stuff[0]? $YEAR, $MONTH, $DAY, $HOUR, $MINUTE, $SECOND and
>> $WEEKDAY.
>> Though I never used this myself.
>>
>> [0] http://lists.gnu.org/archive/html/grub-devel/2008-08/msg00274.html
>
> Hmm, it would have been nice to know about this before. I haven't
> succeeded in getting these variables to work so far today though. The
> "set" command doesn't reflect that they exist, "echo $WEEKDAY" just
> shows a blank line, and an if statement utilizing the variables always
> returns "error: false"
>
> Am I missing something?
>
> --
> Chris Umphress <http://www.epicvoyage.org>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Bean
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Datecheck command (date comparison)
2009-05-21 3:01 ` Bean
@ 2009-05-21 4:00 ` Chris Umphress
0 siblings, 0 replies; 5+ messages in thread
From: Chris Umphress @ 2009-05-21 4:00 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, May 20, 2009 at 10:01 PM, Bean <bean123ch@gmail.com> wrote:
> Hi,
>
> Have you forgotten "insmod datehook" ?
It looks like I was. Thanks!
--
Chris Umphress <http://www.epicvoyage.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-05-21 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-20 14:43 Datecheck command (date comparison) Chris Umphress
2009-05-20 15:35 ` Felix Zielcke
2009-05-20 21:36 ` Chris Umphress
2009-05-21 3:01 ` Bean
2009-05-21 4:00 ` Chris Umphress
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.