[hackers] [sbase] Respect exit status in head(1) || sin
commit 2a84dd507611a461efbddffe8f8f6b2b518fed67
Author: sin <sin_AT_2f30.org>
Date: Thu Nov 20 22:39:29 2014 +0000
Respect exit status in head(1)
diff --git a/head.c b/head.c
index f2c6206..ec40446 100644
--- a/head.c
+++ b/head.c
_AT_@ -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
_AT_@ -20,6 +20,7 @@ main(int argc, char *argv[])
{
long n = 10;
FILE *fp;
+ int ret = 0;
ARGBEGIN {
case 'n':
_AT_@ -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
Received on Thu Nov 20 2014 - 23:40:07 CET
This archive was generated by hypermail 2.3.0
: Thu Nov 20 2014 - 23:48:09 CET