From e591c5ecff8985e58fd9e85b06d1d12dea6dbfd8 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Tue, 2 Oct 2018 23:05:58 +0900 Subject: [PATCH] Throw a return value on a bad open in tee --- apps/tee.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/tee.c b/apps/tee.c index 2ceeedb0..3e9b985c 100644 --- a/apps/tee.c +++ b/apps/tee.c @@ -14,6 +14,7 @@ int main(int argc, char * argv[]) { int append = 0; + int ret_val = 0; int opt; while ((opt = getopt(argc, argv, "ai")) != -1) { @@ -34,6 +35,7 @@ int main(int argc, char * argv[]) { files[i] = fopen(argv[j], append ? "a" : "w"); if (!files[i]) { fprintf(stderr, "%s: %s: %s\n", argv[0], argv[j], strerror(errno)); + ret_val = 1; file_count--; continue; } else { @@ -56,5 +58,5 @@ int main(int argc, char * argv[]) { fclose(files[i]); } - return 0; + return ret_val; }