Subject: Re: textproc/nbsed broken on non-NetBSD systems
To: Robert Lillack <>
From: Robert Lillack <>
List: tech-pkg
Date: 04/29/2005 22:29:35
This is a multi-part message in MIME format.
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Robert Lillack wrote:

> I think at least a switch to force building getopt, when SunOS <=5.8
> is detected in libnbcompat's autoconf script is the badly needed.

Actually I got to revoke this. nbsed did use libnbcompat's getopt.
And that's the broken one (correct me, if I'm wrong, it's late here):

% gcc -o getopt-test getopt-test.c libnbcompat-20041024/libnbcompat.a
% ./getopt-test abc --x && echo "ok" || echo "nono"

% gcc -o getopt-test getopt-test.c
% ./getopt-test abc --x && echo "ok" || echo "nono"

Both tests done on the Solaris 8 box I was referring to, before.
getopt-test.c is attached. (For this tiny test I don't even consider the
GNU way broken, but changing the defines you should have a good starting
point for autoconf magic)

What do I overlook?

Cheers, Rob.
   +- Robert Lillack ------------------ -+
  /  Max Planck Institute for Mathematics in the Sciences  /
+- Leipzig, Germany ----------- phone: +49-341-9959-693 -+

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

/* call like this: ./getopt abc --x */
#include <unistd.h>

#define GETOPT_POSIX		0
#define GETOPT_BROKEN		1

extern int optind;

int main(int argc, char **argv) {
  if (getopt(argc, argv, "x") != -1) {

  argc -= optind;
  if (argc < 2) {