Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/sed add -u (unbuffered output) after GNU sed.
details: https://anonhg.NetBSD.org/src/rev/37830d3a8ab1
branches: trunk
changeset: 330013:37830d3a8ab1
user: christos <christos%NetBSD.org@localhost>
date: Tue Jun 17 16:39:02 2014 +0000
description:
add -u (unbuffered output) after GNU sed.
diffstat:
usr.bin/sed/main.c | 23 +++++++++++++++++------
usr.bin/sed/sed.1 | 8 +++++---
2 files changed, 22 insertions(+), 9 deletions(-)
diffs (94 lines):
diff -r 8892665bb8e5 -r 37830d3a8ab1 usr.bin/sed/main.c
--- a/usr.bin/sed/main.c Tue Jun 17 15:37:40 2014 +0000
+++ b/usr.bin/sed/main.c Tue Jun 17 16:39:02 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.24 2014/06/06 12:46:54 joerg Exp $ */
+/* $NetBSD: main.c,v 1.25 2014/06/17 16:39:02 christos Exp $ */
/*-
* Copyright (c) 2013 Johann 'Myrkraverk' Oskarsson.
@@ -39,7 +39,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.24 2014/06/06 12:46:54 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.25 2014/06/17 16:39:02 christos Exp $");
#ifdef __FBSDID
__FBSDID("$FreeBSD: head/usr.bin/sed/main.c 252231 2013-06-26 04:14:19Z pfg $");
#endif
@@ -137,7 +137,7 @@
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':
@@ -177,6 +177,16 @@
case 'n':
nflag = 1;
break;
+ case 'u':
+#ifdef _IONBF
+ c = setvbuf(stdout, NULL, _IONBF, 0);
+#else
+ c = -1;
+ errno = EOPNOTSUPP;
+#endif
+ if (c)
+ warn("setting unbuffered output failed");
+ break;
default:
case '?':
usage();
@@ -208,9 +218,10 @@
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 [-Ealnu] [-i[<extension>]] [file ...]\n"
+ "\t%s [-Ealnu] [-i[<extension>]] [-e script] ... [-f script_file]"
+ " ... [file ...]\n", getprogname(), getprogname());
exit(1);
}
diff -r 8892665bb8e5 -r 37830d3a8ab1 usr.bin/sed/sed.1
--- a/usr.bin/sed/sed.1 Tue Jun 17 15:37:40 2014 +0000
+++ b/usr.bin/sed/sed.1 Tue Jun 17 16:39:02 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sed.1,v 1.34 2014/06/06 14:36:38 christos Exp $
+.\" $NetBSD: sed.1,v 1.35 2014/06/17 16:39:02 christos Exp $
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -32,7 +32,7 @@
.\" @(#)sed.1 8.2 (Berkeley) 12/30/93
.\" $FreeBSD: head/usr.bin/sed/sed.1 259132 2013-12-09 18:57:20Z eadler $
.\"
-.Dd December 9, 2013
+.Dd June 17, 2014
.Dt SED 1
.Os
.Sh NAME
@@ -40,7 +40,7 @@
.Nd stream editor
.Sh SYNOPSIS
.Nm
-.Op Fl Ealnr
+.Op Fl Ealnru
.Ar command
.Op Ar
.Nm
@@ -149,6 +149,8 @@
Same as
.Fl E
for compatibility with GNU sed.
+.It Fl u
+Make output unbuffered.
.El
.Pp
The form of a
Home |
Main Index |
Thread Index |
Old Index