[Top][All Lists]

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

Re: How to suppress the error message "no such device" during execution

From: Jordan Uggla
Subject: Re: How to suppress the error message "no such device" during execution of a configuration file
Date: Sun, 19 Feb 2012 20:46:12 -0800

On Fri, Feb 17, 2012 at 5:59 AM, Arbiel Perlacremaz
<address@hidden> wrote:
> Thank you for your reply.
> I've appended the configuration file. As comments are in french, let me tell
> you its purpose.
> The situation is the following : Grub, /boot are supposed to be on a USB key
> from where booting is done. The OS is supposed to be on a HDD partition
> named "cielos". If this partition is not defined, then the configuration
> file looks for another partition, whose name has previously been recorded
> into the environment variable oshote, unless : no name has been recorded yet
> or the user presses the Ctrl key to indicate the present oshote partition
> must not be booted from.
> If this second partition can not be found, or if oshote is not defined yet
> or if the oshote partition must not been booted from, then the configuration
> file reads input from the user to get the name of the partition to boot
> from, until such a partition can be found, or until no name is entered. If
> that letter cas, the configuration file should halt (in fact halt does not
> work - I've opened a ticket that for - and I use the reboot command)
> Your comments are welcome, as I'm not an expert programmer.

It is hard to understand with all of the comments in French, but it
appears from what I do understand to be well written, I only see two
problems. First, you should quote your variables:

Another problem I see is in this line (and a similar problem in others):
if [ -z ${root} ]; ! [ -z ${oshote} ]; ! keystatus --ctrl; then

Condititional statements in grub script work the same as conditional
statements in bash (almost all features common to bash and grub-script
work the same way, and where they don't it's probably a bug).

In this case what you're telling grub to do is first run "[ -z ${root}
]" and throw away its exit code, then run "! [ -z ${oshote} ]" which,
after reversing the boolean value of the command, will also discard
the exit code, and finally run "! keystatus --ctrl" and use that
command's exit code as the *only* determinant for the if statement.

What I assume you meant is something like this:
if [ -z ${root} ] && ! [ -z ${oshote} ] && ! keystatus --ctrl; then

The only problem is that the && operator requires grub from bzr, it's
not in the released grub 1.99. If you need to use grub 1.99 then I
would recommend you use multiple nested if statements. Ugly, but it
should work.

If you'd like, I can help you make what will probably be a better
interface though. I would recommend that instead of prompting the user
to type in a label, you instead make a dynamically generated menu with
an entry for each label which can be found on the system. The
"menuentry" command can be used in loops and conditionals just like
any other command, so this can be done fairly easily.

Jordan Uggla (Jordan_U on

reply via email to

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