From lichray@gmail.com  Mon May 28 17:56:37 2012
Return-Path: <lichray@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5A5091065673
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 May 2012 17:56:37 +0000 (UTC)
	(envelope-from lichray@gmail.com)
Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 1505E8FC1F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 May 2012 17:56:37 +0000 (UTC)
Received: by yenl8 with SMTP id l8so1868938yen.13
        for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 May 2012 10:56:36 -0700 (PDT)
Received: by 10.50.104.167 with SMTP id gf7mr5146913igb.38.1338227796181;
        Mon, 28 May 2012 10:56:36 -0700 (PDT)
Received: from localhost ([99.141.182.146])
        by mx.google.com with ESMTPS id va9sm6424038igb.17.2012.05.28.10.56.35
        (version=SSLv3 cipher=OTHER);
        Mon, 28 May 2012 10:56:35 -0700 (PDT)
Message-Id: <4fc3bc53.c998320a.5106.ffffa0ec@mx.google.com>
Date: Mon, 28 May 2012 10:56:35 -0700 (PDT)
From: Zhihao Yuan <lichray@gmail.com>
Reply-To: Zhihao Yuan <lichray@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] stdbuf(1) does not allow cmd with no parameters
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         168415
>Category:       bin
>Synopsis:       [PATCH] stdbuf(1) does not allow cmd with no parameters
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jlh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 28 18:00:12 UTC 2012
>Closed-Date:    Fri Feb 08 22:27:03 UTC 2013
>Last-Modified:  Fri Feb  8 22:30:00 UTC 2013
>Originator:     Zhihao Yuan
>Release:        FreeBSD 8.3-STABLE amd64
>Organization:
Northern Illinois University
>Environment:
System: FreeBSD elitebook.hp 8.3-STABLE FreeBSD 8.3-STABLE #1 r235265: Fri May 11 07:06:26 CDT 2012 lichray@elitebook.hp:/usr/obj/usr/src/sys/HOUKAGO amd64


	
>Description:
	
	But usage() says it's allowed.
>How-To-Repeat:
	
	stdbuf -o L dmesg
>Fix:

	

--- patch-stdbuf.c begins here ---
Index: usr.bin/stdbuf/stdbuf.c
===================================================================
--- usr.bin/stdbuf/stdbuf.c	(revision 236135)
+++ usr.bin/stdbuf/stdbuf.c	(working copy)
@@ -72,7 +72,7 @@
 	}
 	argc -= optind;
 	argv += optind;
-	if (argc < 2)
+	if (argc < 1)
 		usage(0);
 
 	if (ibuf != NULL && setenv("_STDBUF_I", ibuf, 1) == -1)
--- patch-stdbuf.c ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jlh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Thu Nov 1 20:28:59 UTC 2012 
Responsible-Changed-Why:  
Over to committer. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/168415: commit references a PR
Date: Mon, 14 Jan 2013 11:03:21 +0000 (UTC)

 Author: jlh
 Date: Mon Jan 14 11:03:13 2013
 New Revision: 245418
 URL: http://svnweb.freebsd.org/changeset/base/245418
 
 Log:
   Allow commands without any additional arguments, as stated in the
   manpage.  While here, exit early when there is nothing to do.
   
   PR:            168415
   Submitted by:  Zhihao Yuan (initial version)
   MFC after:     1 week
   Approved by:   kib (mentor)
 
 Modified:
   head/usr.bin/stdbuf/stdbuf.c
 
 Modified: head/usr.bin/stdbuf/stdbuf.c
 ==============================================================================
 --- head/usr.bin/stdbuf/stdbuf.c	Mon Jan 14 11:00:06 2013	(r245417)
 +++ head/usr.bin/stdbuf/stdbuf.c	Mon Jan 14 11:03:13 2013	(r245418)
 @@ -72,8 +72,8 @@ main(int argc, char *argv[])
  	}
  	argc -= optind;
  	argv += optind;
 -	if (argc < 2)
 -		usage(0);
 +	if (argc == 0)
 +		exit(0);
  
  	if (ibuf != NULL && setenv("_STDBUF_I", ibuf, 1) == -1)
  		warn("Failed to set environment variable: %s=%s",
 _______________________________________________
 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: open->patched 
State-Changed-By: jlh 
State-Changed-When: Fri Feb 8 21:35:26 UTC 2013 
State-Changed-Why:  
Committed to -CURRENT. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/168415: commit references a PR
Date: Fri,  8 Feb 2013 22:13:37 +0000 (UTC)

 Author: jlh
 Date: Fri Feb  8 22:13:20 2013
 New Revision: 246566
 URL: http://svnweb.freebsd.org/changeset/base/246566
 
 Log:
   MFC r245418:
   Allow commands without any additional arguments, as stated in the
   manpage.  While here, exit early when there is nothing to do.
   
   PR:            168415
   Submitted by:  Zhihao Yuan (initial version)
   
   MFC r245419:
   Remove stray tabs.
   
   Submitted by:	kib
 
 Modified:
   stable/9/usr.bin/stdbuf/stdbuf.c
 Directory Properties:
   stable/9/usr.bin/stdbuf/   (props changed)
 
 Modified: stable/9/usr.bin/stdbuf/stdbuf.c
 ==============================================================================
 --- stable/9/usr.bin/stdbuf/stdbuf.c	Fri Feb  8 21:15:47 2013	(r246565)
 +++ stable/9/usr.bin/stdbuf/stdbuf.c	Fri Feb  8 22:13:20 2013	(r246566)
 @@ -39,7 +39,7 @@ extern char *__progname;
  static void
  usage(int s)
  {
 -	
 +
  	fprintf(stderr, "Usage: %s [-e 0|L|<sz>] [-i 0|L|<sz>] [-o 0|L|<sz>] "
  	    "<cmd> [args ...]\n", __progname);
  	exit(s);
 @@ -72,8 +72,8 @@ main(int argc, char *argv[])
  	}
  	argc -= optind;
  	argv += optind;
 -	if (argc < 2)
 -		usage(0);
 +	if (argc == 0)
 +		exit(0);
  
  	if (ibuf != NULL && setenv("_STDBUF_I", ibuf, 1) == -1)
  		warn("Failed to set environment variable: %s=%s",
 @@ -94,7 +94,7 @@ main(int argc, char *argv[])
  
  	if (i < 0 || putenv(preload1) == -1)
  		warn("Failed to set environment variable: LD_PRELOAD");
 -	
 +
  	preload0 = getenv("LD_32_PRELOAD");
  	if (preload0 == NULL)
  		i = asprintf(&preload1, "LD_32_PRELOAD=" LIBSTDBUF32);
 _______________________________________________
 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: jlh 
State-Changed-When: Fri Feb 8 22:27:02 UTC 2013 
State-Changed-Why:  
Merged to stable/8 and stable/9.  Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/168415: commit references a PR
Date: Fri,  8 Feb 2013 22:23:30 +0000 (UTC)

 Author: jlh
 Date: Fri Feb  8 22:23:22 2013
 New Revision: 246567
 URL: http://svnweb.freebsd.org/changeset/base/246567
 
 Log:
   MFC r245418:
   Allow commands without any additional arguments, as stated in the
   manpage.  While here, exit early when there is nothing to do.
   
   PR:            168415
   Submitted by:  Zhihao Yuan (initial version)
   
   MFC r245419:
   Remove stray tabs.
   
   Submitted by:	kib
 
 Modified:
   stable/8/usr.bin/stdbuf/stdbuf.c
 Directory Properties:
   stable/8/usr.bin/stdbuf/   (props changed)
 
 Modified: stable/8/usr.bin/stdbuf/stdbuf.c
 ==============================================================================
 --- stable/8/usr.bin/stdbuf/stdbuf.c	Fri Feb  8 22:13:20 2013	(r246566)
 +++ stable/8/usr.bin/stdbuf/stdbuf.c	Fri Feb  8 22:23:22 2013	(r246567)
 @@ -39,7 +39,7 @@ extern char *__progname;
  static void
  usage(int s)
  {
 -	
 +
  	fprintf(stderr, "Usage: %s [-e 0|L|<sz>] [-i 0|L|<sz>] [-o 0|L|<sz>] "
  	    "<cmd> [args ...]\n", __progname);
  	exit(s);
 @@ -72,8 +72,8 @@ main(int argc, char *argv[])
  	}
  	argc -= optind;
  	argv += optind;
 -	if (argc < 2)
 -		usage(0);
 +	if (argc == 0)
 +		exit(0);
  
  	if (ibuf != NULL && setenv("_STDBUF_I", ibuf, 1) == -1)
  		warn("Failed to set environment variable: %s=%s",
 @@ -94,7 +94,7 @@ main(int argc, char *argv[])
  
  	if (i < 0 || putenv(preload1) == -1)
  		warn("Failed to set environment variable: LD_PRELOAD");
 -	
 +
  	preload0 = getenv("LD_32_PRELOAD");
  	if (preload0 == NULL)
  		i = asprintf(&preload1, "LD_32_PRELOAD=" LIBSTDBUF32);
 _______________________________________________
 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:
