Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jan 2011 18:43:15 +0000 (UTC)
From:      Ulrich Spoerlein <uqs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r217890 - head/usr.bin/getopt
Message-ID:  <201101261843.p0QIhFU5085746@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: uqs
Date: Wed Jan 26 18:43:15 2011
New Revision: 217890
URL: http://svn.freebsd.org/changeset/base/217890

Log:
  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@bishopston.net>
  MFC after:	1 week

Modified:
  head/usr.bin/getopt/getopt.1

Modified: head/usr.bin/getopt/getopt.1
==============================================================================
--- head/usr.bin/getopt/getopt.1	Wed Jan 26 18:03:03 2011	(r217889)
+++ head/usr.bin/getopt/getopt.1	Wed Jan 26 18:43:15 2011	(r217890)
@@ -1,6 +1,6 @@
 .\" $FreeBSD$
 .\"
-.Dd July 7, 2010
+.Dd January 26, 2011
 .Dt GETOPT 1
 .Os
 .Sh NAME
@@ -54,8 +54,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
@@ -63,22 +62,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:



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