Treat the '-' as meaning standard input.

Obtained from:	NetBSD
This commit is contained in:
Sergey Kandaurov 2014-05-04 12:20:40 +00:00
parent bc1e8f56ff
commit c401df0176
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=265319
2 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -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: