Hi Thank you Jordan.
So it appears that, when a command (as false, or true , or keystatus) is
used as an argument to another command (as [), it is interpreted as a
character string. Testing a character string returns the boolean value
"false" if the length of the string is 0, otherwise, it returns "true".
I suppose I could also write
keystatus --ctrl && [ -f "${prefix}/greffons/menuentry.cfg" ] &&
source "${prefix}/greffons/menuentry.cfg ;
Le 17/11/2015 23:07, Jordan Uggla a écrit :
> On Tue, Nov 17, 2015 at 8:54 AM, Arbiel (gmx) <[email protected]>
> wrote:
>> Hi
>>
>> I'm using Grub2 (v2.00).
>>
>> In a configfile'd configuration file, I've inserted the following line
>>
>> if [ keystatus --ctrl -a -f "${prefix}/greffons/menuentry.cfg" ];
>> then source "${prefix}/greffons/menuentry.cfg"; fi;
> You're making a common bash programming mistake, explained here:
> http://mywiki.wooledge.org/BashPitfalls#if_.5Bgrep_foo_myfile.5D
> (grub-script is modeled off of bash syntax).
>
>> To my understanding, this means " if the control key is pressed down and
>> the requested file exists, then source the file.
> To achieve that in grub-script you could use the following:
>
> if keystatus --ctrl; then
> if [ -f ${prefix}/greffons/menuentry.cfg" ]; then
> source "${prefix}/greffons/menuentry.cfg"
> fi
> fi
>
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Help-grub mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-grub
