sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 8c99cfae86c203dd9c4e9b6cbeaba92809f18d0c
parent e3c51eb17d7c57cfa6343c8eea81715ad9c91792
Author: sin <sin@2f30.org>
Date:   Sun Jan 25 20:26:30 +0000

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

Diffstat:
fold.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fold.c b/fold.c @@ -73,6 +73,7 @@ main(int argc, char *argv[]) { size_t width = 80; FILE *fp; + int r = 0; ARGBEGIN { case 'b': @@ -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); @@ -104,5 +106,5 @@ main(int argc, char *argv[]) } } - return 0; + return r; }