All of lore.kernel.org
 help / color / mirror / Atom feed
* 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

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.