From 4c830ecd4fa501a32bdc5e2fb3af9f90d56ce72e Mon Sep 17 00:00:00 2001 From: bde Date: Tue, 3 Oct 1995 12:46:37 +0000 Subject: Fix exit status. `cat no-such-file >/dev/null' exited with status 0. This has been broken since cat's own err() function was sloppily replaced by the library functions warn() and err(). --- bin/cat/cat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bin/cat') diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 3f68251..276b787 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: cat.c,v 1.2 1994/09/24 02:53:26 davidg Exp $ */ #ifndef lint @@ -128,6 +128,7 @@ cook_args(argv) fp = stdin; else if ((fp = fopen(*argv, "r")) == NULL) { warn("%s", *argv); + rval = 1; ++argv; continue; } @@ -196,6 +197,7 @@ cook_buf(fp) } if (ferror(fp)) { warn("%s", filename); + rval = 1; clearerr(fp); } if (ferror(stdout)) @@ -216,6 +218,7 @@ raw_args(argv) fd = fileno(stdin); else if ((fd = open(*argv, O_RDONLY, 0)) < 0) { warn("%s", *argv); + rval = 1; ++argv; continue; } @@ -248,6 +251,8 @@ raw_cat(rfd) for (off = 0; nr; nr -= nw, off += nw) if ((nw = write(wfd, buf + off, nr)) < 0) err(1, "stdout"); - if (nr < 0) + if (nr < 0) { warn("%s", filename); + rval = 1; + } } -- cgit v1.1