grub-devel
[Top][All Lists]
Advanced

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

Re: [BUG] GRUBs option parsing needs fixing


From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: [BUG] GRUBs option parsing needs fixing
Date: Thu, 08 Mar 2012 15:15:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20120216 Icedove/8.0

On 08.03.2012 14:12, Andreas Vogel wrote:
Hi all,

I start a new thread with this mail in order to have a thread on its own
for this subject.
Please don't CC Colin Watson (or me for that matter) for everything, it's bad tone.
In another thread we've already had some discussion about GRUBs option
parsing. I wanna summarize and describe here about the issue.

Right now I see 2 problems with GRUBs argument parsing:

1) GRUBs argument parsing is not POSIX compliant.
We don't follow POSIX.

2) Optional option argument is not handled correctly (and not according
to POSIX/GNU standard)
Well it's possible to do something like

=== modified file 'grub-core/lib/arg.c'
--- grub-core/lib/arg.c    2012-02-08 18:26:01 +0000
+++ grub-core/lib/arg.c    2012-03-08 14:13:21 +0000
@@ -294,7 +291,8 @@
         }
           else
         {
-          if (opt->type != ARG_TYPE_NONE)
+          if (opt->type != ARG_TYPE_NONE
+ && !(opt->flags & GRUB_ARG_OPTION_OPTIONAL))
             {
               if (curarg + 1 < argc)
             {
@@ -333,7 +331,8 @@
       opt = find_long (cmd->options, arg + 2, arglen);

       if (!option && argv[curarg + 1] && argv[curarg + 1][0] != '-'
- && opt && opt->type != ARG_TYPE_NONE)
+ && opt && opt->type != ARG_TYPE_NONE
+ && !(opt->flags & GRUB_ARG_OPTION_OPTIONAL))
         option = argv[++curarg];

       if (!opt && (cmd->cmd->flags & GRUB_COMMAND_ACCEPT_DASH))

But it would break configurations like -h com0 or -s root.

--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko




reply via email to

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