svn commit: r218656 - stable/8/usr.bin/getopt
Ulrich Spoerlein
uqs at FreeBSD.org
Sun Feb 13 19:02:26 UTC 2011
Author: uqs
Date: Sun Feb 13 19:02:26 2011
New Revision: 218656
URL: http://svn.freebsd.org/changeset/base/218656
Log:
MFH r217890
Fix typo in example getopt(1) script: $i vs $1 [1]
While here apply style hammer.
PR: docs/154289 [1]
Submitted by: Jamie Landeg Jones <jamie at bishopston.net>
Modified:
stable/8/usr.bin/getopt/getopt.1
Directory Properties:
stable/8/usr.bin/getopt/ (props changed)
Modified: stable/8/usr.bin/getopt/getopt.1
==============================================================================
--- stable/8/usr.bin/getopt/getopt.1 Sun Feb 13 18:46:34 2011 (r218655)
+++ stable/8/usr.bin/getopt/getopt.1 Sun Feb 13 19:02:26 2011 (r218656)
@@ -1,6 +1,6 @@
.\" $FreeBSD$
.\"
-.Dd July 7, 2010
+.Dd January 26, 2011
.Dt GETOPT 1
.Os
.Sh NAME
@@ -55,8 +55,7 @@ which requires an argument.
args=\`getopt abo: $*\`
# you should not use \`getopt abo: "$@"\` since that would parse
# the arguments differently from what the set command below does.
-if [ $? -ne 0 ]
-then
+if [ $? -ne 0 ]; then
echo 'Usage: ...'
exit 2
fi
@@ -64,22 +63,23 @@ set \-\- $args
# You cannot use the set command with a backquoted getopt directly,
# since the exit code from getopt would be shadowed by those of set,
# which is zero by definition.
-while true;
-do
- case "$1"
- in
- \-a|\-b)
- echo flag $i set; sflags="${i#-}$sflags";
- shift;;
- \-o)
- echo oarg is "'"$2"'"; oarg="$2"; shift;
- shift;;
- \-\-)
- shift; break;;
+while true; do
+ case "$1" in
+ \-a|\-b)
+ echo "flag $1 set"; sflags="${1#-}$sflags"
+ shift
+ ;;
+ \-o)
+ echo "oarg is '$2'"; oarg="$2"
+ shift; shift
+ ;;
+ \-\-)
+ shift; break
+ ;;
esac
done
-echo single-char flags: "'"$sflags"'"
-echo oarg is "'"$oarg"'"
+echo "single-char flags: '$sflags'"
+echo "oarg is '$oarg'"
.Ed
.Pp
This code will accept any of the following as equivalent:
More information about the svn-src-stable
mailing list