Bug 168415 - [PATCH] stdbuf(1) does not allow cmd with no parameters
Summary: [PATCH] stdbuf(1) does not allow cmd with no parameters
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 8.3-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Jeremie Le Hen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-28 19:00 UTC by lichray
Modified: 2013-02-08 22:30 UTC (History)
0 users

See Also:


Attachments
patch-stdbuf.c (350 bytes, text/plain)
2012-05-28 19:00 UTC, lichray
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description lichray 2012-05-28 19:00:12 UTC
	
	But usage() says it's allowed.

How-To-Repeat: 	
	stdbuf -o L dmesg
Comment 1 Jaakko Heinonen freebsd_committer freebsd_triage 2012-11-01 20:28:59 UTC
Responsible Changed
From-To: freebsd-bugs->jlh

Over to committer.
Comment 2 dfilter service freebsd_committer freebsd_triage 2013-01-14 11:03:21 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"
Comment 3 Jeremie Le Hen freebsd_committer freebsd_triage 2013-02-08 21:35:26 UTC
State Changed
From-To: open->patched

Committed to -CURRENT.
Comment 4 dfilter service freebsd_committer freebsd_triage 2013-02-08 22:13:37 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"
Comment 5 dfilter service freebsd_committer freebsd_triage 2013-02-08 22:23:30 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"
Comment 6 Jeremie Le Hen freebsd_committer freebsd_triage 2013-02-08 22:27:02 UTC
State Changed
From-To: patched->closed

Merged to stable/8 and stable/9.  Thanks!