Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 30 Sep 2012 23:06:55 +0200
From: Daniel Cegiełka <>
Subject: Re: better compatibility with bsd getopt()

2012/9/30 John Spencer <>:

> an application that relies on non-posix getopt behaviour should come with a
> configure check and use an alternate impl if the getopt detected is not
> compatible.
> almost any program does so already, but for those that don't (like iptables)
> you can use (tarball available on
> sabotage mirror, or in downloads section of the page).
> this bundles the netbsd getopt into a standalone library that can easily be
> linked to programs.

Without optreset support some BSD programs will not be able to
compile, like patch:

	if (!Argc)
	optreset = optind = 1;
	while ((ch = getopt_long(Argc, Argv, options, longopts, NULL)) != -1) {
		switch (ch) {
		case 'b':;content-type=text%2Fplain

Your example shows that the gnu-getopt is also a problem. It may be
better to keep musl clean and solve these problems outside of musl. So
a good solution for us is to use a getopt() wrapper for problematic apps,
like gnu_getopt() or bsd_getopt().


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.