summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-27 10:34:35 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-27 10:34:35 -0500
commitb542ed3f41237f23bacc801a1f4f4946b887779f (patch)
treed69dd7c24dca9af316b1741c9bdb81006370f5c3 /eval.c
parente5543a849302e9ce3d5e83693283736c6a26a86c (diff)
downloadbfs-b542ed3f41237f23bacc801a1f4f4946b887779f.tar.xz
Don't repeat reported error messages from bftw().
Fixes #7.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index b8e9a1b..7d56f8d 100644
--- a/eval.c
+++ b/eval.c
@@ -554,6 +554,8 @@ struct callback_args {
const struct cmdline *cmdline;
/** Eventual return value from eval_cmdline(). */
int ret;
+ /** The last error code seen. */
+ int last_error;
};
/**
@@ -565,6 +567,7 @@ static enum bftw_action cmdline_callback(struct BFTW *ftwbuf, void *ptr) {
const struct cmdline *cmdline = args->cmdline;
if (ftwbuf->typeflag == BFTW_ERROR) {
+ args->last_error = ftwbuf->error;
pretty_error(cmdline->stderr_colors, "'%s': %s\n", ftwbuf->path, strerror(ftwbuf->error));
return BFTW_SKIP_SUBTREE;
}
@@ -663,9 +666,14 @@ int eval_cmdline(const struct cmdline *cmdline) {
};
for (size_t i = 0; i < cmdline->nroots; ++i) {
+ args.last_error = 0;
+
if (bftw(cmdline->roots[i], cmdline_callback, nopenfd, cmdline->flags, &args) != 0) {
args.ret = -1;
- perror("bftw()");
+
+ if (errno != args.last_error) {
+ perror("bftw()");
+ }
}
}