Skip to content

Commit

Permalink
parse: Allow -files0-from an empty set of paths
Browse files Browse the repository at this point in the history
This follows a behaviour change in GNU findutils 4.9.0.
  • Loading branch information
tavianator committed Aug 14, 2023
1 parent a630783 commit 92f0c51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ struct parser_state {
char **mount_arg;
/** An "-xdev" argument, if any. */
char **xdev_arg;
/** A "-files0-from" argument, if any. */
char **files0_arg;
/** A "-files0-from -" argument, if any. */
char **files0_stdin_arg;
/** An "-ok"-type expression, if any. */
Expand Down Expand Up @@ -1318,7 +1316,6 @@ static struct bfs_expr *parse_files0_from(struct parser_state *state, int arg1,
return NULL;
}

state->files0_arg = expr->argv;
const char *from = expr->argv[1];

FILE *file;
Expand Down Expand Up @@ -1350,7 +1347,7 @@ static struct bfs_expr *parse_files0_from(struct parser_state *state, int arg1,
}

if (file == stdin) {
state->files0_stdin_arg = state->files0_arg;
state->files0_stdin_arg = expr->argv;
} else {
fclose(file);
}
Expand Down Expand Up @@ -3720,7 +3717,6 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) {
.prune_arg = NULL,
.mount_arg = NULL,
.xdev_arg = NULL,
.files0_arg = NULL,
.files0_stdin_arg = NULL,
.ok_expr = NULL,
.now = ctx->now,
Expand Down Expand Up @@ -3748,11 +3744,8 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) {
goto fail;
}

if (darray_length(ctx->paths) == 0) {
if (!state.implicit_root) {
parse_argv_error(&state, state.files0_arg, 2, "No root paths specified.\n");
goto fail;
} else if (parse_root(&state, ".") != 0) {
if (darray_length(ctx->paths) == 0 && state.implicit_root) {
if (parse_root(&state, ".") != 0) {
goto fail;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/gnu/files0_from_none.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
! printf "" | invoke_bfs -files0-from -
printf "" | bfs_diff -files0-from -

0 comments on commit 92f0c51

Please sign in to comment.