svn commit: r265319 - head/usr.bin/nl

Sergey Kandaurov pluknet at FreeBSD.org
Sun May 4 12:20:41 UTC 2014


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:


More information about the svn-src-head mailing list