summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-10-04 13:10:01 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-10-04 13:11:31 -0400
commitb0282202ce8b361110ef32b18e7159edc604929d (patch)
tree1cdc77a142b45959d54ab6f23ca94294c38f69fa
parentf39733d053528ca234f955401ef8d8ecd84762a4 (diff)
downloadbfs-b0282202ce8b361110ef32b18e7159edc604929d.tar.xz
parse: More accurate error reporting for cfdup()
-rw-r--r--parse.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 4e3f763..fadf0c5 100644
--- a/parse.c
+++ b/parse.c
@@ -3479,9 +3479,15 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) {
}
ctx->colors = parse_colors(getenv("LS_COLORS"));
+
ctx->cout = cfdup(stdout, use_color ? ctx->colors : NULL);
+ if (!ctx->cout) {
+ perror("cfdup()");
+ goto fail;
+ }
+
ctx->cerr = cfdup(stderr, use_color ? ctx->colors : NULL);
- if (!ctx->cout || !ctx->cerr) {
+ if (!ctx->cerr) {
perror("cfdup()");
goto fail;
}