summaryrefslogtreecommitdiffstats
path: root/bin/cat/cat.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1995-10-03 12:46:37 +0000
committerbde <bde@FreeBSD.org>1995-10-03 12:46:37 +0000
commit4c830ecd4fa501a32bdc5e2fb3af9f90d56ce72e (patch)
treef769afa2e6ebc7426a3dbcaba66084cd0156e016 /bin/cat/cat.c
parent5fdb3714e972a0430709b748326017eb2a2ea658 (diff)
downloadFreeBSD-src-4c830ecd4fa501a32bdc5e2fb3af9f90d56ce72e.zip
FreeBSD-src-4c830ecd4fa501a32bdc5e2fb3af9f90d56ce72e.tar.gz
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().
Diffstat (limited to 'bin/cat/cat.c')
-rw-r--r--bin/cat/cat.c9
1 files changed, 7 insertions, 2 deletions
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;
+ }
}
OpenPOWER on IntegriCloud