When a file name of "-" is given, read from standard input (SUSv3)
This commit is contained in:
parent
1ccb024996
commit
2292a0fbef
@ -61,8 +61,13 @@ utility selects portions of each line (as specified by
|
||||
.Ar list )
|
||||
from each
|
||||
.Ar file
|
||||
(or the standard input by default), and writes them to the
|
||||
standard output.
|
||||
and writes them to the standard output.
|
||||
If no
|
||||
.Ar file
|
||||
arguments are specified, or a file argument is a single dash
|
||||
.Pq Ql \&- ,
|
||||
.Nm
|
||||
reads from from the standard input.
|
||||
The items specified by
|
||||
.Ar list
|
||||
can be in terms of column position or in terms of fields delimited
|
||||
|
@ -119,6 +119,9 @@ main(argc, argv)
|
||||
rval = 0;
|
||||
if (*argv)
|
||||
for (; *argv; ++argv) {
|
||||
if (strcmp(*argv, "-") == 0)
|
||||
fcn(stdin, "stdin");
|
||||
else {
|
||||
if (!(fp = fopen(*argv, "r"))) {
|
||||
warn("%s", *argv);
|
||||
rval = 1;
|
||||
@ -127,6 +130,7 @@ main(argc, argv)
|
||||
fcn(fp, *argv);
|
||||
(void)fclose(fp);
|
||||
}
|
||||
}
|
||||
else
|
||||
fcn(stdin, "stdin");
|
||||
exit(rval);
|
||||
|
Loading…
Reference in New Issue
Block a user