After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 303166 - g_option_context_parse loses '-'
g_option_context_parse loses '-'
Status: RESOLVED DUPLICATE of bug 168008
Product: glib
Classification: Platform
Component: general
2.6.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2005-05-05 18:57 UTC by Thomas Leonard
Modified: 2005-05-05 20:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas Leonard 2005-05-05 18:57:14 UTC
Version details: Debian's 2.6.4-1

GLib's option parser removes '-' from argv. This breaks programs which read from
stdin (several GTK+ applications recently stopped working because of this).

Test case:

#include <stdio.h>
#include <gtk/gtk.h>

int main(int argc, char **argv) {
	GOptionContext *option_context;

	option_context = g_option_context_new (NULL);
	g_option_context_set_ignore_unknown_options (option_context, TRUE);

	printf("argv[1] = %s\n", argv[1]);
	g_option_context_parse (option_context, &argc, &argv, NULL);
	printf("argv[1] = %s\n", argv[1]);

	return 0;
}

This produces:

$ cc `pkg-config --cflags --libs gtk+-2.0`    t.c   -o t
$ ./t -
argv[1] = -
argv[1] = (null)
Comment 1 Matthias Clasen 2005-05-05 20:08:34 UTC

*** This bug has been marked as a duplicate of 168008 ***