help-grub
[Top][All Lists]
Advanced

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

Re: Testing a key with keystatus seems to fail


From: Jordan Uggla
Subject: Re: Testing a key with keystatus seems to fail
Date: Tue, 17 Nov 2015 14:07:35 -0800

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:
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

-- 
Jordan Uggla (Jordan_U on irc.freenode.net)



reply via email to

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