Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2014 21:41:30 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267692 - head/usr.bin/sed
Message-ID:  <201406202141.s5KLfU2J047433@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Fri Jun 20 21:41:30 2014
New Revision: 267692
URL: http://svnweb.freebsd.org/changeset/base/267692

Log:
  Add -u (unbuffered output) after GNU sed.
  
  Obtained from:	NetBSD
  MFC after:	1 week

Modified:
  head/usr.bin/sed/main.c
  head/usr.bin/sed/sed.1

Modified: head/usr.bin/sed/main.c
==============================================================================
--- head/usr.bin/sed/main.c	Fri Jun 20 21:35:39 2014	(r267691)
+++ head/usr.bin/sed/main.c	Fri Jun 20 21:41:30 2014	(r267692)
@@ -132,7 +132,7 @@ main(int argc, char *argv[])
 	fflag = 0;
 	inplace = NULL;
 
-	while ((c = getopt(argc, argv, "EI:ae:f:i:lnr")) != -1)
+	while ((c = getopt(argc, argv, "EI:ae:f:i:lnru")) != -1)
 		switch (c) {
 		case 'r':		/* Gnu sed compat */
 		case 'E':
@@ -168,6 +168,16 @@ main(int argc, char *argv[])
 		case 'n':
 			nflag = 1;
 			break;
+		case 'u':
+#ifdef _IONBF
+			c = setvbuf(stdout, NULL, _IONBF, 0);
+#else
+			c = -1;
+			errno = EOPNOTSUPP;
+#endif
+			if (c)
+				warnx("setting unbuffered output failed");
+			break;
 		default:
 		case '?':
 			usage();
@@ -199,9 +209,10 @@ main(int argc, char *argv[])
 static void
 usage(void)
 {
-	(void)fprintf(stderr, "%s\n%s\n",
-		"usage: sed script [-Ealn] [-i extension] [file ...]",
-		"       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]");
+	(void)fprintf(stderr,
+	    "usage: %s script [-Ealnru] [-i[<extension>]] [file ...]\n"
+	    "\t%s [-Ealnu] [-i[<extension>]] [-e script] ... [-f script_file]"
+	    " ... [file ...]\n", getprogname(), getprogname());
 	exit(1);
 }
 

Modified: head/usr.bin/sed/sed.1
==============================================================================
--- head/usr.bin/sed/sed.1	Fri Jun 20 21:35:39 2014	(r267691)
+++ head/usr.bin/sed/sed.1	Fri Jun 20 21:41:30 2014	(r267692)
@@ -31,7 +31,7 @@
 .\"	@(#)sed.1	8.2 (Berkeley) 12/30/93
 .\" $FreeBSD$
 .\"
-.Dd December 9, 2013
+.Dd June 20, 2014
 .Dt SED 1
 .Os
 .Sh NAME
@@ -39,7 +39,7 @@
 .Nd stream editor
 .Sh SYNOPSIS
 .Nm
-.Op Fl Ealnr
+.Op Fl Ealnru
 .Ar command
 .Op Ar
 .Nm
@@ -148,6 +148,8 @@ option suppresses this behavior.
 Same as
 .Fl E
 for compatibility with GNU sed.
+.It Fl u
+Make output unbuffered.
 .El
 .Pp
 The form of a



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