summaryrefslogtreecommitdiffstats
path: root/src/parse.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-08-16 09:24:30 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-08-16 09:33:34 -0400
commitc3f52a2e3c22a8e05b60f94b8344501b14e87794 (patch)
tree6d5c3d6fec021ba5814443e44b971e59ed5157e9 /src/parse.c
parente130daf99c1828c554c27d546274712624b81faa (diff)
downloadbfs-c3f52a2e3c22a8e05b60f94b8344501b14e87794.tar.xz
New -noerror option to suppress error messages
Closes: https://github.com/tavianator/bfs/issues/142
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/parse.c b/src/parse.c
index ddb67aa..fe0c10d 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -1817,6 +1817,14 @@ static struct bfs_expr *parse_newerxy(struct bfs_parser *parser, int arg1, int a
}
/**
+ * Parse -noerror.
+ */
+static struct bfs_expr *parse_noerror(struct bfs_parser *parser, int arg1, int arg2) {
+ parser->ctx->ignore_errors = true;
+ return parse_nullary_option(parser);
+}
+
+/**
* Parse -nogroup.
*/
static struct bfs_expr *parse_nogroup(struct bfs_parser *parser, int arg1, int arg2) {
@@ -2759,6 +2767,8 @@ static struct bfs_expr *parse_help(struct bfs_parser *parser, int arg1, int arg2
cfprintf(cout, " ${blu}-mount${rs}\n");
cfprintf(cout, " Don't descend into other mount points (same as ${blu}-xdev${rs} for now, but will\n");
cfprintf(cout, " skip mount points entirely in the future)\n");
+ cfprintf(cout, " ${blu}-noerror${rs}\n");
+ cfprintf(cout, " Ignore any errors that occur during traversal\n");
cfprintf(cout, " ${blu}-nohidden${rs}\n");
cfprintf(cout, " Exclude hidden files\n");
cfprintf(cout, " ${blu}-noleaf${rs}\n");
@@ -3053,6 +3063,7 @@ static const struct table_entry parse_table[] = {
{"-newer", BFS_TEST, parse_newer, BFS_STAT_MTIME},
{"-newer", BFS_TEST, parse_newerxy, .prefix = true},
{"-nocolor", BFS_OPTION, parse_color, false},
+ {"-noerror", BFS_OPTION, parse_noerror},
{"-nogroup", BFS_TEST, parse_nogroup},
{"-nohidden", BFS_TEST, parse_nohidden},
{"-noignore_readdir_race", BFS_OPTION, parse_ignore_races, false},