diff options
author | pluknet <pluknet@FreeBSD.org> | 2014-05-04 12:20:40 +0000 |
---|---|---|
committer | pluknet <pluknet@FreeBSD.org> | 2014-05-04 12:20:40 +0000 |
commit | 4226abee66810abe924a6a433fe619e9454ff79b (patch) | |
tree | 8b6f841d443e2fd60200523b4fdbc94647d71521 /usr.bin/nl | |
parent | 000f6e777d1cdc96e15c55bda087e7ab580ca626 (diff) | |
download | FreeBSD-src-4226abee66810abe924a6a433fe619e9454ff79b.zip FreeBSD-src-4226abee66810abe924a6a433fe619e9454ff79b.tar.gz |
Treat the '-' as meaning standard input.
Obtained from: NetBSD
Diffstat (limited to 'usr.bin/nl')
-rw-r--r-- | usr.bin/nl/nl.1 | 16 | ||||
-rw-r--r-- | usr.bin/nl/nl.c | 3 |
2 files changed, 12 insertions, 7 deletions
diff --git a/usr.bin/nl/nl.1 b/usr.bin/nl/nl.1 index 554e18d..cb67c04 100644 --- a/usr.bin/nl/nl.1 +++ b/usr.bin/nl/nl.1 @@ -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 diff --git a/usr.bin/nl/nl.c b/usr.bin/nl/nl.c index 9c2ae64..1770b78 100644 --- a/usr.bin/nl/nl.c +++ b/usr.bin/nl/nl.c @@ -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: |