aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/getopt
diff options
context:
space:
mode:
authorUlrich Spörlein <uqs@FreeBSD.org>2011-01-26 18:43:15 +0000
committerUlrich Spörlein <uqs@FreeBSD.org>2011-01-26 18:43:15 +0000
commit200520dfce240ee35549198547e98122552cba4f (patch)
tree2c25e8397756e71bb40819a884d91e87944da19d /usr.bin/getopt
parente691be70f94e9109310f7e3090529d1c30c5707a (diff)
downloadsrc-200520dfce240ee35549198547e98122552cba4f.tar.gz
src-200520dfce240ee35549198547e98122552cba4f.zip
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
Notes
Notes: svn path=/head/; revision=217890
Diffstat (limited to 'usr.bin/getopt')
-rw-r--r--usr.bin/getopt/getopt.134
1 files changed, 17 insertions, 17 deletions
diff --git a/usr.bin/getopt/getopt.1 b/usr.bin/getopt/getopt.1
index c57b19c6402c..d8271372a922 100644
--- a/usr.bin/getopt/getopt.1
+++ b/usr.bin/getopt/getopt.1
@@ -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: