patch to add getopt parsing to expr
    Joe Talbott 
    josepht at cstone.net
       
    Tue Jan 20 07:20:41 PST 2009
    
    
  
On Tue, Jan 20, 2009 at 02:02:28PM +0100, Joerg Sonnenberger wrote:
> On Mon, Jan 19, 2009 at 11:30:55PM -0500, Joe Talbott wrote:
> > +	while ((ch = getopt(argc, argv, "-")) != -1) {
> 
> The use of getopt here is wrong. Besides, using getopt is taking a
> sledgehammer to crack a nut. Attached is the corresponding fix for
> NetBSD, the explicit check for having at least one argument is better
> anyway.
> 
> Joerg
Since POSIX requires arguments beginning with '-' to be options
shouldn't the following result in an error?
expr -d=zzz : '.*=\(.*\)'
Where:
expr -- -d=zzz : '.*=\(.*\)'
should be the correct usage.  I opted to use getopt() since FreeBSD's
expr accepts -e.  The "-" was inadvertently left in the patch.
Thanks,
Joe
    
    
More information about the Bugs
mailing list