diff options
author | Jason McIntyre <jmc@cvs.openbsd.org> | 2006-01-14 09:29:52 +0000 |
---|---|---|
committer | Jason McIntyre <jmc@cvs.openbsd.org> | 2006-01-14 09:29:52 +0000 |
commit | ba0a79daaad7a2a9fe8d5e6890863d1f2f3fef2e (patch) | |
tree | dde21b935e3e1b212261ed88fa32a94b4b5dc533 /usr.bin/getopt | |
parent | b43891cd6064c31969bb094b6175bceeef33efbb (diff) |
update the example and synopsis so that we are checking the
exit value of getopt itself, not `set';
example merged from current freebsd page;
problem reported by nordin; ok millert
Diffstat (limited to 'usr.bin/getopt')
-rw-r--r-- | usr.bin/getopt/getopt.1 | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/getopt/getopt.1 b/usr.bin/getopt/getopt.1 index a6b0b9466bf..51763c22840 100644 --- a/usr.bin/getopt/getopt.1 +++ b/usr.bin/getopt/getopt.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: getopt.1,v 1.9 2006/01/13 22:13:53 jmc Exp $ -*- nroff -*- +.\" $OpenBSD: getopt.1,v 1.10 2006/01/14 09:29:51 jmc Exp $ -*- nroff -*- .\" .\" This material, written by Henry Spencer, was released by him .\" into the public domain and is thus not subject to any copyright. @@ -10,7 +10,7 @@ .Nm getopt .Nd parse command options .Sh SYNOPSIS -.Nm set -- `getopt optstring $*` +.Nm args=`getopt optstring $*`; errcode=$?; set -- $args .Sh DESCRIPTION .Nm is used to break up options in command lines for easy parsing by @@ -46,12 +46,13 @@ and the option .Fl o , which requires an argument. .Bd -literal -offset indent -set -- `getopt abo: $*` -if test $? != 0 +args=`getopt abo: $*` +if [ $? -ne 0 ] then echo 'Usage: ...' exit 2 fi +set -- $args for i do case "$i" |