diff options
author | tjr <tjr@FreeBSD.org> | 2002-05-24 09:56:18 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-05-24 09:56:18 +0000 |
commit | 2292a0fbefedec1f30c7492f750fe741b83985eb (patch) | |
tree | 88b6a98540665b285c9792ced968e18a4cba821b /usr.bin/cut/cut.c | |
parent | 1ccb024996b7c1dbe79c7e2759dae4dffa33eb67 (diff) | |
download | FreeBSD-src-2292a0fbefedec1f30c7492f750fe741b83985eb.zip FreeBSD-src-2292a0fbefedec1f30c7492f750fe741b83985eb.tar.gz |
When a file name of "-" is given, read from standard input (SUSv3)
Diffstat (limited to 'usr.bin/cut/cut.c')
-rw-r--r-- | usr.bin/cut/cut.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c index 12d0e83..1f67f2a 100644 --- a/usr.bin/cut/cut.c +++ b/usr.bin/cut/cut.c @@ -119,13 +119,17 @@ main(argc, argv) rval = 0; if (*argv) for (; *argv; ++argv) { - if (!(fp = fopen(*argv, "r"))) { - warn("%s", *argv); - rval = 1; - continue; + if (strcmp(*argv, "-") == 0) + fcn(stdin, "stdin"); + else { + if (!(fp = fopen(*argv, "r"))) { + warn("%s", *argv); + rval = 1; + continue; + } + fcn(fp, *argv); + (void)fclose(fp); } - fcn(fp, *argv); - (void)fclose(fp); } else fcn(stdin, "stdin"); |