GNOME Bugzilla – Bug 577638
G_OPTION_ARG_CALLBACK + G_OPTION_FLAG_OPTIONAL_ARG no parse "-"value
Last modified: 2010-08-05 06:25:47 UTC
...sorry for my english... { "option" ... G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, callback_function, ... } g_print("value = %s"); in callback_function... from cmdline --option=-3 --- value = -3 --option -3 --- value = NULL is a bug or i'm very dork = bischero = fava?
...sorry for my english... { "option" ... G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, callback_function, ... } g_print("value = %s",value); into the callback_function... from cmdline --option=-3 --- value = -3 --option -3 --- value = NULL is it a bug or am i a very dork = bischero = fava?
The code explicitly uses NULL in this case: if (!OPTIONAL_ARG (&group->entries[j])) { value = (*argv)[idx + 1]; add_pending_null (context, &((*argv)[idx + 1]), NULL); *new_idx = idx + 1; } else { if ((*argv)[idx + 1][0] == '-') => here: value = NULL; else { value = (*argv)[idx + 1]; add_pending_null (context, &((*argv)[idx + 1]), NULL); *new_idx = idx + 1; } } but whether that's a bug or a feature remains to be seen.
...sorry for my english... I'm not sure, I think the question is not in the function "parse_short_option" but in the function "parse_long_option" (goption.c) ... else { if ((*argv)[*idx + 1][0] == '-') { gboolean retval; retval = parse_arg (context, group, &group->entries[j], => NULL, option_name, error); *parsed = TRUE; g_free (option_name); return retval; } ... "=> NULL" == "data = NULL into the "parse_arg" function" == "value = NULL into the callback_function" I said pure bullshit?
I don't think that this is a bug. Otherwise we'd introduce obscurity. Imagine you have "--option" just like you described above. And you have "--triple-foo"/"-3"; how should one interpret "app --option -3" is "-3" an argument to --option or do you want to do triple-foo but with a short command option? IMHO this is not a bug.
I agree