Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 May 2014 12:20:40 +0000 (UTC)
From:      Sergey Kandaurov <pluknet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r265319 - head/usr.bin/nl
Message-ID:  <201405041220.s44CKeDR060222@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pluknet
Date: Sun May  4 12:20:40 2014
New Revision: 265319
URL: http://svnweb.freebsd.org/changeset/base/265319

Log:
  Treat the '-' as meaning standard input.
  
  Obtained from:	NetBSD

Modified:
  head/usr.bin/nl/nl.1
  head/usr.bin/nl/nl.c

Modified: head/usr.bin/nl/nl.1
==============================================================================
--- head/usr.bin/nl/nl.1	Sun May  4 10:14:25 2014	(r265318)
+++ head/usr.bin/nl/nl.1	Sun May  4 12:20:40 2014	(r265319)
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 26, 2005
+.Dd May 4, 2014
 .Dt NL 1
 .Os
 .Sh NAME
@@ -71,12 +71,16 @@
 The
 .Nm
 utility reads lines from the named
+.Ar file ,
+applies a configurable line numbering filter operation,
+and writes the result to the standard output.
+If
 .Ar file
-or the standard input if the
-.Ar file
-argument is omitted,
-applies a configurable line numbering filter operation and writes the result
-to the standard output.
+is a single dash
+.Pq Sq Fl
+or absent,
+.Nm
+reads from the standard input.
 .Pp
 The
 .Nm

Modified: head/usr.bin/nl/nl.c
==============================================================================
--- head/usr.bin/nl/nl.c	Sun May  4 10:14:25 2014	(r265318)
+++ head/usr.bin/nl/nl.c	Sun May  4 12:20:40 2014	(r265319)
@@ -242,7 +242,8 @@ main(int argc, char *argv[])
 	case 0:
 		break;
 	case 1:
-		if (freopen(argv[0], "r", stdin) == NULL)
+		if (strcmp(argv[0], "-") != 0 &&
+		    freopen(argv[0], "r", stdin) == NULL)
 			err(EXIT_FAILURE, "%s", argv[0]);
 		break;
 	default:



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