GNOME Bugzilla – Bug 729563
GOption: A short option's value is included in G_OPTION_REMAINING
Last modified: 2014-05-06 00:34:48 UTC
Created attachment 275886 [details] Test case After a call to g_option_context_set_ignore_unknown_options(context, TRUE), the values of short options are included in the array returned by a G_OPTION_REMAINING option. If G_OPTION_REMAINING is not used, the short options' values are (correctly) removed from argv[]. Some results with the attached test case: $ ./testcase --number 4 --text=hello file1 file2 ignore=0:0, remaining=0:0, number=4, text=hello, files=, argv= ./testcase file1 file2 $ ./testcase -r --number 4 --text=hello file1 file2 ignore=0:0, remaining=1:1, number=4, text=hello, files= file1 file2, argv= ./testcase $ ./testcase -n 4 -t hello file1 file2 ignore=0:0, remaining=0:0, number=4, text=hello, files=, argv= ./testcase file1 file2 $ ./testcase -r -n 4 -t hello file1 file2 ignore=0:0, remaining=1:1, number=4, text=hello, files= file1 file2, argv= ./testcase $ ./testcase -i --number 4 --text=hello file1 file2 ignore=1:1, remaining=0:0, number=4, text=hello, files=, argv= ./testcase file1 file2 $ ./testcase -ri --number 4 --text=hello file1 file2 ignore=1:1, remaining=1:1, number=4, text=hello, files= file1 file2, argv= ./testcase $ ./testcase -i -n 4 -t hello file1 file2 ignore=1:1, remaining=0:0, number=4, text=hello, files=, argv= ./testcase file1 file2 $ ./testcase -ri -n 4 -t hello file1 file2 ignore=1:1, remaining=1:1, number=4, text=hello, files= 4 hello file1 file2, argv= ./testcase The last result is wrong. "4" and "hello" shall not be considered remaining options. I will add a patch.
Created attachment 275887 [details] [review] patch: goption: Don't include parsed option values in G_OPTION_REMAINING
thanks, I've turned you testcase into a testcase in glib/tests/option-context.c