From lonerr@dev2.rambler.ru  Fri Mar 27 09:26:39 2009
Return-Path: <lonerr@dev2.rambler.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 66DD4106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 27 Mar 2009 09:26:39 +0000 (UTC)
	(envelope-from lonerr@dev2.rambler.ru)
Received: from mail01.park.rambler.ru (mail01.park.rambler.ru [81.19.66.124])
	by mx1.freebsd.org (Postfix) with ESMTP id 1B9148FC1C
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 27 Mar 2009 09:26:37 +0000 (UTC)
	(envelope-from lonerr@dev2.rambler.ru)
Received: from dev2.rambler.ru (dev2.rambler.ru [10.12.2.2])
	by mail01.park.rambler.ru (Postfix) with ESMTP id 530374B94C79
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 27 Mar 2009 12:26:36 +0300 (MSK)
Received: from dev2.rambler.ru (localhost [127.0.0.1])
	by dev2.rambler.ru (8.14.2/8.14.2) with ESMTP id n2R9QaxQ086443
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 27 Mar 2009 12:26:36 +0300 (MSK)
	(envelope-from lonerr@dev2.rambler.ru)
Received: (from lonerr@localhost)
	by dev2.rambler.ru (8.14.2/8.14.2/Submit) id n2R9Qa2f086442;
	Fri, 27 Mar 2009 12:26:36 +0300 (MSK)
	(envelope-from lonerr)
Message-Id: <200903270926.n2R9Qa2f086442@dev2.rambler.ru>
Date: Fri, 27 Mar 2009 12:26:36 +0300 (MSK)
From: "Oleg A. Mamontov" <oleg@mamontov.net>
Reply-To: "Oleg A. Mamontov" <oleg@mamontov.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: Error in getopt (1) manual EXAMPLES section
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         133118
>Category:       docs
>Synopsis:       [patch] Error in getopt (1) manual EXAMPLES section
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bcr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 27 09:30:02 UTC 2009
>Closed-Date:    Wed Jul 21 17:19:00 UTC 2010
>Last-Modified:  Sun Feb 13 19:10:10 UTC 2011
>Originator:     Oleg A. Mamontov
>Release:        FreeBSD 7.0-20080303-SNAP amd64
>Organization:
Rambler Internet Holding
>Environment:
System: FreeBSD dev2.rambler.ru 7.0-20080303-SNAP FreeBSD 7.0-20080303-SNAP #1: Tue Apr 8 13:54:52 MSD 2008 root@dev2.rambler.ru:/usr/src/sys/amd64/compile/DEV2 amd64
>Description:
The man page for getopt(1) contains incorrect example.

for i
do
    case "$i"
    in
       ...
done

Variable $@ expanded to list of options and their values (if any).
Loop variable ($i) will contain both (but should contain only options).

This invalid example was imported from NetBSD cvs in Revision 1.1:
http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/getopt/getopt.1?rev=1.1;content-type=text%2Fx-cvsweb-markup

Later this was fixed in NetBSD:
http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/getopt/getopt.1?rev=1.10&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

>How-To-Repeat:

>Fix:
This piece of code should look like this:
while true;
do
    case "$1"
    in
       ...
done


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: bcr 
State-Changed-When: Wed Jul 7 17:49:12 UTC 2010 
State-Changed-Why:  
A patch based on your suggestion was committed to HEAD (r209772). 
MFC pending, so I'll leave it in this state until then. 


Responsible-Changed-From-To: freebsd-doc->bcr 
Responsible-Changed-By: bcr 
Responsible-Changed-When: Wed Jul 7 17:49:12 UTC 2010 
Responsible-Changed-Why:  
A patch based on your suggestion was committed to HEAD (r209772). 
MFC pending, so I'll leave it in this state until then. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=133118 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/133118: commit references a PR
Date: Wed,  7 Jul 2010 17:44:22 +0000 (UTC)

 Author: bcr (doc committer)
 Date: Wed Jul  7 17:44:09 2010
 New Revision: 209772
 URL: http://svn.freebsd.org/changeset/base/209772
 
 Log:
   Fix an error in the EXAMPLES section of getopt(1), which is based on
   the same fix present in NetBSD.
   
   Note: the getopt man page contains more antique information like this.
   An overhaul of the man page and/or sync with NetBSD would be the right
   thing to do. But since this is out of the scope of the PR, I'll leave
   it as it is for now.
   
   PR:             docs/133118
   Submitted by:   Oleg A. Mamontov (oleg at mamontov dot net)
   Discussed with: jilles@
   MFC after:      2 weeks
 
 Modified:
   head/usr.bin/getopt/getopt.1
 
 Modified: head/usr.bin/getopt/getopt.1
 ==============================================================================
 --- head/usr.bin/getopt/getopt.1	Wed Jul  7 17:20:16 2010	(r209771)
 +++ head/usr.bin/getopt/getopt.1	Wed Jul  7 17:44:09 2010	(r209772)
 @@ -1,6 +1,6 @@
  .\" $FreeBSD$
  .\"
 -.Dd April 3, 1999
 +.Dd July 7, 2010
  .Dt GETOPT 1
  .Os
  .Sh NAME
 @@ -64,9 +64,9 @@ 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.
 -for i
 +while true;
  do
 -	case "$i"
 +	case "$1"
  	in
  		\-a|\-b)
  			echo flag $i set; sflags="${i#-}$sflags";
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: bcr 
State-Changed-When: Wed Jul 21 17:18:03 UTC 2010 
State-Changed-Why:  
MFC is done, PR closed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=133118 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/133118: commit references a PR
Date: Wed, 21 Jul 2010 17:11:36 +0000 (UTC)

 Author: bcr (doc committer)
 Date: Wed Jul 21 17:11:26 2010
 New Revision: 210354
 URL: http://svn.freebsd.org/changeset/base/210354
 
 Log:
   MFC r209772:
   
   Fix an error in the EXAMPLES section of getopt(1), which is based on
   the same fix present in NetBSD.
   
   Note: the getopt man page contains more antique information like this.
   An overhaul of the man page and/or sync with NetBSD would be the right
   thing to do. But since this is out of the scope of the PR, I'll leave
   it as it is for now.
   
   PR:             docs/133118
   Submitted by:   Oleg A. Mamontov (oleg at mamontov dot net)
   Discussed with: jilles@
 
 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	Wed Jul 21 13:29:00 2010	(r210353)
 +++ stable/8/usr.bin/getopt/getopt.1	Wed Jul 21 17:11:26 2010	(r210354)
 @@ -1,6 +1,6 @@
  .\" $FreeBSD$
  .\"
 -.Dd April 3, 1999
 +.Dd July 7, 2010
  .Dt GETOPT 1
  .Os
  .Sh NAME
 @@ -64,9 +64,9 @@ 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.
 -for i
 +while true;
  do
 -	case "$i"
 +	case "$1"
  	in
  		\-a|\-b)
  			echo flag $i set; sflags="${i#-}$sflags";
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/133118: commit references a PR
Date: Sun, 13 Feb 2011 19:07:25 +0000 (UTC)

 Author: uqs
 Date: Sun Feb 13 19:07:17 2011
 New Revision: 218657
 URL: http://svn.freebsd.org/changeset/base/218657
 
 Log:
   MFH r209772,217890
   
   Fix an error in the EXAMPLES section of getopt(1), which is based on
   the same fix present in NetBSD.
   
   Fix typo in example getopt(1) script: $i vs $1 [1]
   While here apply style hammer.
   
   PR:		docs/133118, docs/154289 [1]
   Submitted by:	Oleg A. Mamontov, Jamie Landeg Jones
 
 Modified:
   stable/7/usr.bin/getopt/getopt.1
 Directory Properties:
   stable/7/usr.bin/getopt/   (props changed)
 
 Modified: stable/7/usr.bin/getopt/getopt.1
 ==============================================================================
 --- stable/7/usr.bin/getopt/getopt.1	Sun Feb 13 19:02:26 2011	(r218656)
 +++ stable/7/usr.bin/getopt/getopt.1	Sun Feb 13 19:07:17 2011	(r218657)
 @@ -1,6 +1,6 @@
  .\" $FreeBSD$
  .\"
 -.Dd April 3, 1999
 +.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.
 -for i
 -do
 -	case "$i"
 -	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:
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
