From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1M6n1A-0003C7-Je for mharc-grub-devel@gnu.org; Wed, 20 May 2009 10:43:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6n18-0003Bf-26 for grub-devel@gnu.org; Wed, 20 May 2009 10:43:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6n13-0003BR-J5 for grub-devel@gnu.org; Wed, 20 May 2009 10:43:37 -0400 Received: from [199.232.76.173] (port=56726 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6n13-0003BO-E0 for grub-devel@gnu.org; Wed, 20 May 2009 10:43:33 -0400 Received: from mail-ew0-f162.google.com ([209.85.219.162]:46105) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M6n13-0007QD-3u for grub-devel@gnu.org; Wed, 20 May 2009 10:43:33 -0400 Received: by ewy6 with SMTP id 6so577825ewy.42 for ; Wed, 20 May 2009 07:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=jDwKPfKZyFAXaQRoWLjiNGsgmgKjKOeL5QClpUi0aLQ=; b=ggLW32hZDFgyxrXDFcriNus167MNJRsRqaa4ixnoAgwyVWH/hzUaCNlCJQuG4yUScH GCgJH5UBuVCU690gMeyvgKTwF/NLxq6wZqYp7hIDWF/TwGKsgcnwG4Ei3U9Haz/SgzxK IYqmr8qk+1YE8y6b6jC6TpQrUTGM0tnRtma+E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=mX+0uETDqcXJgvbUy0jR1XO+Sg9PF6RBF6T1y5rgVbvZbAYAWvjfy0lwj3TsOfOuyJ S2IR6JhDXJtQnzwrsl530yuV/ObtbTsuV5F/RwRQsvu/eO9AAsmxVe1q6afJoNkL3kfu 1t+U1DQwKswo/fMtJUrlTXWSz6w4LLJHE/UrQ= MIME-Version: 1.0 Received: by 10.210.65.2 with SMTP id n2mr3728735eba.19.1242830610564; Wed, 20 May 2009 07:43:30 -0700 (PDT) Date: Wed, 20 May 2009 09:43:30 -0500 Message-ID: <1f29b8940905200743j4f8da5a8rf43fa7348878dc3a@mail.gmail.com> From: Chris Umphress To: GRUB Development Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Datecheck command (date comparison) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2009 14:43:38 -0000 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