History log of /freebsd-10.1-release/usr.bin/getopt/getopt.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 200462 13-Dec-2009 delphij

Revert most part of 200420 as requested, as more review and polish is
needed.


# 200420 11-Dec-2009 delphij

Remove unneeded header includes from usr.bin/ except contributed code.

Tested with: make universe


# 179020 15-May-2008 brooks

getopt.c is public domain. Add a comment to that effect.

Remove confusing README.

PR: bin/98911
Submitted by: Jason McIntyre <jmc at kerhand dot co dot uk>
Obtained from: OpenBSD
MFC after: 3 days


# 102944 04-Sep-2002 dwmalone

ANSIify function definitions.
Add some constness to avoid some warnings.
Remove use register keyword.
Deal with missing/unneeded extern/prototypes.
Some minor type changes/casts to avoid warnings.

Reviewed by: md5


# 99112 30-Jun-2002 obrien

Consistently use FBSDID


# 95657 28-Apr-2002 markm

Minor nit; return(foo) from main rather than exit(foo).


# 87283 03-Dec-2001 dwmalone

Warns cleanup (just make main return an int).


# 78718 24-Jun-2001 dd

Include missing header files which define functions for which gcc has
builtins (e.g., exit, strcmp).


# 65428 04-Sep-2000 imp

getopt and friends are declared in <unistd.h>
getopt returns -1 not EOF.


# 45279 03-Apr-1999 cracauer

Back out part of previous commit.

Arguments with whitespaces are easy to fix, but in combination with
shell metachars that should not be evaluated it is very hard, probably
impossible to fix without going to a line-oriented solution.

Next time I will believe Henry Spencer when he says "this looks easy
to fix but isn't".


# 45271 03-Apr-1999 cracauer

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.

PR: bin/5845


# 24360 29-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 194 26-Jul-1993 nate

Added getopt(1) from NetBSD