From: Andreas Vogel <Andreas.Vogel@anvo-it.de>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>,
"Colin Watson" <cjwatson@ubuntu.com>
Subject: [BUG] GRUBs option parsing needs fixing
Date: Thu, 08 Mar 2012 14:12:30 +0100 [thread overview]
Message-ID: <4F58B03E.2050908@anvo-it.de> (raw)
In-Reply-To: <4F54DF19.7000804@anvo-it.de>
Hi all,
I start a new thread with this mail in order to have a thread on its own
for this subject.
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.
Problem:
POSIX (and GNU too) recommends (see
http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html):
"An option and its argument may or may not appear as separate tokens.
(In other words, the whitespace separating them is optional.) Thus, ‘-o
foo’ and ‘-ofoo’ are equivalent."
This is doesn't hold for GRUB.
When I try
load_env -fenv
an error message
error: unknown argument '-e'.
is returned.
Solution:
The GRUB argument parser needs to be fixed so that short options are
parsed according to POSIX/GNU standards.
2) Optional option argument is not handled correctly (and not according
to POSIX/GNU standard)
Problem:
Right now the GRUB argument parser doesn't handle optional arguments
properly and it doesn't comply to POSIX/GNU standards.
For short options parsing fails for the reason described above and
because the parser allows that the option and its (optional) argument
might be separated with whitespace.
For long options parsing fails too because the parser allows that the
option and its (optional) argument might be separated with whitespace.
Example:
OK: search --file --set --nofloppy /boot/grub/grub.cfg
OK: search --file --set -- /boot/grub/grub.cfg
ERROR: search --file --set /boot/grub/grub.cfg
Solution:
This solution follows just the POSIX/GNU standards for argument syntax
as stated in the above mentioned HTML document.
In order to be able to handle optional arguments for options the GRUB
argument parser needs to implement parsing according to the following
syntax:
a) Short option: e.g. option name 'x' taking an optional argument '<arg>'
Possible options: "-x" or "-x<arg>"
b) Long option: e.g. option name 'xlong' taking an optional argument '<arg>'
Possible options: "--xlong" or "--xlong=<arg>" or "--xlong="
For the third form the upcoming implementation is somehow free to
decide how to interpret that option. Regarding to GNUs getopt() man
page, this form will be interpreted by getopt() as if the option isn't
specified at all (due to a bug). Because that interpretation is based on
a bug and because it might make more sense the third form could/should
be interpreted as if "--xlong" has been specified (meaning: options is
present but without value).
So for both, short and long options taking an optional value, no
whitespace between option and its value (if the value is present) is
allowed.
IMHO the option parsing code in GRUB2 should be fixed as soon as
possible. The later it will be done the more we'll have to fight with
compatibility issues.
Any comments?
Andreas
next prev parent reply other threads:[~2012-03-08 13:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 1:13 Ideas for the future Andreas Vogel
2012-03-05 1:30 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-05 1:35 ` Samuel Thibault
2012-03-05 1:40 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-05 9:23 ` Samuel Thibault
2012-03-05 11:16 ` Andreas Vogel
2012-03-05 12:54 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-05 15:43 ` Andreas Vogel
2012-03-08 13:12 ` Andreas Vogel [this message]
2012-03-08 14:15 ` [BUG] GRUBs option parsing needs fixing Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-08 14:32 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-08 15:03 ` Andreas Vogel
2012-03-08 15:18 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-08 15:28 ` Lennart Sorensen
2012-03-08 15:37 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-08 16:11 ` Andreas Vogel
2012-03-08 15:45 ` Andreas Vogel
2012-03-10 19:50 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-11 0:08 ` Andreas Vogel
2012-03-11 1:01 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-11 1:59 ` Andreas Vogel
2012-03-11 2:15 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-08 15:25 ` Lennart Sorensen
2012-03-08 15:58 ` Andreas Vogel
2012-03-08 15:24 ` Lennart Sorensen
2012-03-08 14:11 ` Ideas for the future Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-08 15:14 ` Andreas Vogel
2012-03-08 15:18 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-05 16:33 ` Andreas Vogel
2012-03-08 14:23 ` Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F58B03E.2050908@anvo-it.de \
--to=andreas.vogel@anvo-it.de \
--cc=cjwatson@ubuntu.com \
--cc=grub-devel@gnu.org \
--cc=phcoder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.