Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 May 2002 09:15:06 -0400
From:      "Brian F. Feldman" <green@FreeBSD.ORG>
To:        Garance A Drosihn <drosih@rpi.edu>
Cc:        "J. Mallett" <jmallett@FreeBSD.ORG>, arch@FreeBSD.ORG
Subject:   Re: cvs commit: src/usr.bin/sed main.c sed.1 
Message-ID:  <200205091315.g49DF6W70696@green.bikeshed.org>
In-Reply-To: Your message of "Wed, 08 May 2002 19:12:40 EDT." <p05111753b8ff5b1e5228@[128.113.24.47]> 

next in thread | previous in thread | raw e-mail | index | archive | help
Garance A Drosihn <drosih@rpi.edu> wrote:
> At 8:21 PM +0000 5/8/02, J. Mallett wrote:
> >Keep in mind you're saying "-; is not a valid option",
> >which while in practice may be safe, may not be the best
> >thing to say.
> 
> But consider, for instance:
> 
>        /bin/echo test -? somestring
> vs:   /bin/echo test -; somestring
> 
> if you don't quote the '-;', then the shell will use it
> as a command-separator before the command ever sees it.
> This seems to be true with sh, csh, and bash on my
> freebsd-current system.  This makes '-;' a very awkward
> flag for a command to use.  Seems like a nice extension
> to getopt(3).

It really does seem, though, that lots of applications reimplement getopt(3) 
(incorrectly) in order to have one or two "frivolous" features.  
Applications which take -o[optarg] and -o [several] [args] seem to be 
none-too-uncommon.  I'd want to try to support them just so that they all 
don't reinvent getopt(3) badly, but then again there's the problem that 
other operating systems would have to adopt the extended getopt syntax, too. 

Lots of applications just use getopt_long(3) instead, which I suppose can 
easily allow for this functionality with GNU arguments just by virtue that 
they cannot be concatenated anyway.  My temptation is not to provide the 
functionality in the system's libraries because that would tend to make 
developers actually use it, and in doing so become unportable to those OSes 
having a different getopt(3) in addition to going against the grain of what 
POSIX wants.

I don't think there's a clean way of doing it without a modified getopt, so 
I'd say that either sed should have its own getopt with that change locally 
or it would just fail to support the Perl syntax.

-- 
Brian Fundakowski Feldman                           \'[ FreeBSD ]''''''''''\
  <> green@FreeBSD.org  <> bfeldman@tislabs.com      \  The Power to Serve! \
 Opinions expressed are my own.                       \,,,,,,,,,,,,,,,,,,,,,,\



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205091315.g49DF6W70696>