Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Apr 1999 14:28:26 -0800 (PST)
From:      <cracauer@FreeBSD.org>
To:        bob@pmr.com, cracauer@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject:   Re: bin/5845
Message-ID:  <199904032228.OAA09764@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
Synopsis: in sh, set -- `getopt ...` always returns zero

State-Changed-From-To: open->closed
State-Changed-By: cracauer
State-Changed-When: Sun Apr 4 00:26:22 MEST 1999
State-Changed-Why: 
Fixed in 4.0-current from today. Will be fixed in 3.x in a few
days. Releases 3.2 and 4.0 should have this change.

The problem wasn't with getopt, but with the example in the manpage.

Here's the log:

1) Fix the case where a shellscript using getopt is called with a
   parameter that has space in it, both in getopt.c and in the manpage
   example. 

2) Fix the example in the manpage. The set(1) command is required to
   return 0 (POSIX 1003.2, section 3.14.11), so you can't test for
   getopt's exit status like the example did:

  #! /bin/sh
  set -- `getopt abo: $*`
  if test $? != 0  # wrong, tests for set's exit status, which is
                   # always zero, no for getopt(1)'s.

Fixes PR bin/5845, which thought it was getopt's fault, but in fact
the manpage was wrong.

I also updated the example to be more useful and updated the BUGS
section.


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




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