mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
head: report file open errors with exitcode 1 (was happily returning 0)
head_main 409 417 +8
This commit is contained in:
parent
272710fe93
commit
0d8736772d
@ -40,7 +40,6 @@ int head_main(int argc, char **argv)
|
|||||||
int count_bytes = 0;
|
int count_bytes = 0;
|
||||||
int header_threshhold = 1;
|
int header_threshhold = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
char *p;
|
char *p;
|
||||||
@ -50,7 +49,7 @@ int head_main(int argc, char **argv)
|
|||||||
|
|
||||||
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
|
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
|
||||||
/* Allow legacy syntax of an initial numeric option without -n. */
|
/* Allow legacy syntax of an initial numeric option without -n. */
|
||||||
if (argc > 1 && argv[1][0] == '-'
|
if (argv[1] && argv[1][0] == '-'
|
||||||
&& isdigit(argv[1][1])
|
&& isdigit(argv[1][1])
|
||||||
) {
|
) {
|
||||||
--argc;
|
--argc;
|
||||||
@ -79,7 +78,6 @@ int head_main(int argc, char **argv)
|
|||||||
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
|
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
|
||||||
GET_COUNT:
|
GET_COUNT:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !ENABLE_FEATURE_FANCY_HEAD
|
#if !ENABLE_FEATURE_FANCY_HEAD
|
||||||
count = xatoul(p);
|
count = xatoul(p);
|
||||||
#else
|
#else
|
||||||
@ -128,10 +126,12 @@ int head_main(int argc, char **argv)
|
|||||||
putchar(c);
|
putchar(c);
|
||||||
}
|
}
|
||||||
if (fclose_if_not_stdin(fp)) {
|
if (fclose_if_not_stdin(fp)) {
|
||||||
bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
|
bb_simple_perror_msg(*argv);
|
||||||
retval = EXIT_FAILURE;
|
retval = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
die_if_ferror_stdout();
|
die_if_ferror_stdout();
|
||||||
|
} else {
|
||||||
|
retval = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
fmt = header_fmt_str;
|
fmt = header_fmt_str;
|
||||||
} while (*++argv);
|
} while (*++argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user