[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grub 'if' expression with 'or' operation
From: |
Lennart Sorensen |
Subject: |
Re: grub 'if' expression with 'or' operation |
Date: |
Tue, 21 Aug 2012 12:41:14 -0400 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Tue, Aug 21, 2012 at 08:18:57AM -0700, Loving, Kent wrote:
> I'm trying to write an expression that will be true if either one of two
> files are present. The expression must return true if either ntldr or bootmgr
> is present on the first partition of the first drive. If either one is
> present I want to boot to windows on that partition.
>
> So I tried:
>
> if [ -e (hd0,msdos1)/ntldr -o -e (hd0,msdos1)/bootmgr ] ; then
> #do stuff to boot windows
>
> This works great if ntldr is present. But if ntldr is NOT present, and
> bootmgr is present, then the test fails. So I reversed the order:
>
> if [ -e (hd0,msdos1)/bootmgr -o -e (hd0,msdos1)/ntldr ] ; then
> #do stuff to boot windows
>
> Which works if bootmgr is present, but not for ntldr.
>
> In other words, it appears that combining expressions with or operation does
> not work. Only the first operand is used. Is the or operation implemented?
>
> I guess I can change separate the expression into two separate if statements.
It seems the whole use of [ -e ... isn't actually covered in the grub
manual at all, other than having an example that uses it.
Poking a bit at the source code I suspect this might work:
if [ ( -e (hd0,msdos1)/ntldr ) -o ( -e (hd0,msdos1)/bootmgr ) ] ; then
#do stuff to boot windows
--
Len Sorensen