[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing a key with keystatus seems to fail

From: Arbiel (gmx)
Subject: Re: Testing a key with keystatus seems to fail
Date: Thu, 19 Nov 2015 14:49:57 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


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) <address@hidden> 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:
> (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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]