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.