DragonFly bugs List (threaded) for 2009-01
DragonFly BSD
DragonFly bugs List (threaded) for 2009-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: patch to add getopt parsing to expr


From: Joe Talbott <josepht@xxxxxxxxxx>
Date: Tue, 20 Jan 2009 10:18:37 -0500
Mail-followup-to: bugs@crater.dragonflybsd.org

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



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]