[hackers] [sbase] fold: Properly report exit status if we fail to open a file || sin

From: <git_AT_suckless.org>
Date: Sun, 25 Jan 2015 21:27:42 +0100 (CET)

commit ea80f4a77a2539955d1b4b7283241fef2dca6091
Author: sin <sin_AT_2f30.org>
Date: Sun Jan 25 20:26:30 2015 +0000

    fold: Properly report exit status if we fail to open a file

diff --git a/fold.c b/fold.c
index 7c29042..9c4624a 100644
--- a/fold.c
+++ b/fold.c
_AT_@ -73,6 +73,7 @@ main(int argc, char *argv[])
 {
         size_t width = 80;
         FILE *fp;
+ int r = 0;
 
         ARGBEGIN {
         case 'b':
_AT_@ -91,12 +92,13 @@ main(int argc, char *argv[])
                 usage();
         } ARGEND;
 
- if (argc == 0)
+ if (argc == 0) {
                 fold(stdin, width);
- else {
+ } else {
                 for (; argc > 0; argc--, argv++) {
                         if (!(fp = fopen(argv[0], "r"))) {
                                 weprintf("fopen %s:", argv[0]);
+ r = 1;
                                 continue;
                         }
                         fold(fp, width);
_AT_@ -104,5 +106,5 @@ main(int argc, char *argv[])
                 }
         }
 
- return 0;
+ return r;
 }
Received on Sun Jan 25 2015 - 21:27:42 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 25 2015 - 21:36:12 CET