sbase

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

commit 2a84dd507611a461efbddffe8f8f6b2b518fed67
parent 8767e4b32060e59432199cefa0e0b626ce9d7adb
Author: sin <sin@2f30.org>
Date:   Thu, 20 Nov 2014 22:39:29 +0000

Respect exit status in head(1)

Diffstat:
head.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/head.c b/head.c @@ -12,7 +12,7 @@ static void head(FILE *, const char *, long); static void usage(void) { - eprintf("usage: %s [-n] [FILE...]\n", argv0); + eprintf("usage: %s [-n lines] [file...]\n", argv0); } int @@ -20,6 +20,7 @@ main(int argc, char *argv[]) { long n = 10; FILE *fp; + int ret = 0; ARGBEGIN { case 'n': @@ -38,14 +39,14 @@ main(int argc, char *argv[]) for (; argc > 0; argc--, argv++) { if (!(fp = fopen(argv[0], "r"))) { weprintf("fopen %s:", argv[0]); + ret = 1; continue; } head(fp, argv[0], n); fclose(fp); } } - - return 0; + return ret; } static void