Subject: textproc/nbsed broken on non-NetBSD systems
To: None <tech-pkg@NetBSD.org>
From: Robert Lillack <lillack@mis.mpg.de>
List: tech-pkg
Date: 04/29/2005 18:28:59
Can anybody confirm that nbsed has a somewhat bad behaviour on systems 
other than NetBSD when called like this:

	nbsed 's/a/b/' -x

IMHO '-x' has to be be interpreted as filename _always_, but nbsed is 
(why?) inconsistent across different operating systems.

Let's take a look at different systems and seds:

1. machine: SunOS 5.8, nbsed from pkgsrc

  % /usr/bin/sed 's/a/b/' -x
  Can't open -x
  >> looks right to me.

  % /usr/bin/sed 's/a/b/' --x
  Can't open --x
  >> ok.

  % /usr/ucb/sed 's/a/b/' -x
  sed: -x: No such file or directory
  >> yepp.

  % /usr/ucb/sed 's/a/b/' --x
  sed: --x: No such file or directory
  >> right.

  % nbsed 's/a/b/' -x
  nbsed: unknown option -- x
  usage:  nbsed [-aEn] script [file ...]
          nbsed [-aEn] [-e script] ... [-f script_file] ... [file ...]
  >> IMHO wrong.

  % nbsed 's/a/b/' --x
  >> OUCH: hangs forever. (This prevents me from being able to build some
     packages where configure calls sed this way)


2. machine: Linux 2.4.whatever (RedHat Enterprise AS 3),
    nbsed from pkgsrc

  % sed 's/a/b/' -x
  sed: invalid option -- x
  Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...
  [one screen of "usage" cut]
  >> wrong behaviour, too.

  % sed 's/a/b/' --x
  sed: unrecognized option `--x'
  Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...
  [--cut---]
  >> wrong. (but at least, it does not hang)

  % nbsed 's/a/b/' -x
  nbsed: invalid option -- x
  usage:  nbsed [-aEn] script [file ...]
          nbsed [-aEn] [-e script] ... [-f script_file] ... [file ...]
  >> wrong. And please compare the error message to the one on the
     Solaris box!

  % nbsed 's/a/b/' --x
  nbsed: invalid option -- -
  usage:  nbsed [-aEn] script [file ...]
          nbsed [-aEn] [-e script] ... [-f script_file] ... [file ...]
  >> wrong here, too. But again, at least it does not hang.


3. machine, NetBSD 2.0, sed from base & nbset from pkgsrc

  % sed 's/a/b/' -x
  sed: -x: No such file or directory
  >> YES!

  % sed 's/a/b/' --x
  sed: --x: No such file or directory
  >> absolutely.

  % nbsed 's/a/b/' -x
  sed: -x: No such file or directory
  >> right! but, why don't you call yourself nbsed?

  % nbsed 's/a/b/' --x
  sed: --x: No such file or directory
  >> this one's right, too. but why only on this machine?

As you can see, on non NetBSD systems, nbsed behaves as wrong as GNU sed 
or even hangs (this is how i found this oddity). Does anybody have a 
clue, what's going on? Has this something todo with broken getopt 
implementations?

Thanks, Rob.
-- 
   +- Robert Lillack ------------------ lillack@mis.mpg.de -+
  /  Max Planck Institute for Mathematics in the Sciences  /
+- Leipzig, Germany ----------- phone: +49-341-9959-693 -+