diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-02-27 10:34:35 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-02-27 10:34:35 -0500 |
commit | b542ed3f41237f23bacc801a1f4f4946b887779f (patch) | |
tree | d69dd7c24dca9af316b1741c9bdb81006370f5c3 /eval.c | |
parent | e5543a849302e9ce3d5e83693283736c6a26a86c (diff) | |
download | bfs-b542ed3f41237f23bacc801a1f4f4946b887779f.tar.xz |
Don't repeat reported error messages from bftw().
Fixes #7.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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()"); + } } } |