Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/getopt cleanup formatting, improve example



details:   https://anonhg.NetBSD.org/src/rev/7a3999f835c7
branches:  trunk
changeset: 479002:7a3999f835c7
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Dec 01 12:03:16 1999 +0000

description:
cleanup formatting, improve example

diffstat:

 usr.bin/getopt/getopt.1 |  38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diffs (75 lines):

diff -r 129ff969f3dd -r 7a3999f835c7 usr.bin/getopt/getopt.1
--- a/usr.bin/getopt/getopt.1   Wed Dec 01 11:41:46 1999 +0000
+++ b/usr.bin/getopt/getopt.1   Wed Dec 01 12:03:16 1999 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: getopt.1,v 1.8 1997/10/19 02:16:57 lukem Exp $
+.\"    $NetBSD: getopt.1,v 1.9 1999/12/01 12:03:16 lukem Exp $
 .Dd June 21, 1993
 .Dt GETOPT 1
 .Os
@@ -15,8 +15,7 @@
 shell procedures, and to check for legal options.
 .Op Optstring
 is a string of recognized option letters (see
-.Xr getopt 3
-);
+.Xr getopt 3) ;
 if a letter is followed by a colon, the option
 is expected to have an argument which may or may not be
 separated from it by white space.
@@ -41,27 +40,28 @@
 and
 .Op b ,
 and the option
-.Op o ,
+.Op c ,
 which requires an argument.
 .Pp
 .Bd -literal -offset indent
-args=\`getopt abo: $*\`
-if test $? != 0
-then
+args=\`getopt abc: $*\`
+if [ $? != 0 ]; then
        echo 'Usage: ...'
        exit 2
 fi
 set \-\- $args
-for i
-do
-       case "$i"
-       in
+for i; do
+       shift
+       case "$i"; in
                \-a|\-b)
-                       flag=$i; shift;;
-               \-o)
-                       oarg=$2; shift; shift;;
+                       flag=$i
+                       ;;
+               \-c)
+                       carg=$1; shift
+                       ;;
                \-\-)
-                       shift; break;;
+                       break
+                       ;;
        esac
 done
 .Ed
@@ -69,10 +69,10 @@
 This code will accept any of the following as equivalent:
 .Pp
 .Bd -literal -offset indent
-cmd \-aoarg file file
-cmd \-a \-o arg file file
-cmd \-oarg -a file file
-cmd \-a \-oarg \-\- file file
+cmd \-acarg file file
+cmd \-a \-c arg file file
+cmd \-carg -a file file
+cmd \-a \-carg \-\- file file
 .Ed
 .Pp
 .St -p1003.2



Home | Main Index | Thread Index | Old Index