Subject: Re: textproc/nbsed broken on non-NetBSD systems
To: None <tech-pkg@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-pkg
Date: 04/29/2005 20:02:20
On Fri, 29 Apr 2005, Robert Lillack wrote:
> 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.
nbsed just used getopt() in a way that works fine on NetBSD. But GNU
getopt likes to interpret "-x" as an option even when it appears after
non-option args.
I suggest one or more of the following fixes or workarounds:
1. Don't try to use nbsed like that. Instead, use
nbsed 's/a/b/' ./-x
2. Set the POSIXLY_CORRECT environment variable to tell GNU getopt()
not to exhibit the bad behaviour.
3. Make nbsed (and all other nb* tools) use getopt() in a
GNU-getopt-compatible way, by passing '+' as the first char of the
option string, and by adding '+' as an explicit error case in the
option processing switch.
4. Make the autoconf stuff in pkgsrc/sysutils/libnbcompat smarter about
deciding when to use its own getopt() implementation instead of the
host OS's native getopt(). If it detects that the native getopt()
has the bad GNU behaviour, it should decide to use its own getopt()
instead.
--apb (Alan Barrett)