From 49415accb857450cdeb4397c31cbe4d6e6e9591f Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 9 Feb 2017 18:35:25 -0500 Subject: Don't close stdin for -ok or -okdir Turns out it violates POSIX, even though GNU find does it. --- eval.c | 9 --------- tests.sh | 13 +++++++------ tests/test_0094.out | 19 +++++++++++++++++++ tests/test_0095.out | 19 +++++++++++++++++++ 4 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 tests/test_0094.out create mode 100644 tests/test_0095.out diff --git a/eval.c b/eval.c index 37bea60..3a97585 100644 --- a/eval.c +++ b/eval.c @@ -468,17 +468,8 @@ bool eval_exec(const struct expr *expr, struct eval_state *state) { exec_chdir(ftwbuf); } - if (expr->exec_flags & EXEC_CONFIRM) { - if (redirect(STDIN_FILENO, "/dev/null", O_RDONLY) < 0) { - perror("redirect()"); - goto exit; - } - } - execvp(argv[0], argv); perror("execvp()"); - - exit: _Exit(EXIT_FAILURE); } diff --git a/tests.sh b/tests.sh index ecaf837..084e8ac 100755 --- a/tests.sh +++ b/tests.sh @@ -609,15 +609,16 @@ function test_0093() { } function test_0094() { - [ "$GNU" ] || return 0 - # -ok should close stdin for the executed command - yes | $BFS basic -ok cat ';' 2>/dev/null + [ "$BSD" ] || return 0 + # -ok should *not* close stdin + # See https://savannah.gnu.org/bugs/?24561 + yes | bfs_diff basic -ok bash -c "printf '%s? ' {} && head -n1" \; 2>/dev/null } function test_0095() { - [ "$GNU" ] || return 0 - # -okdir should close stdin for the executed command - yes | $BFS basic -okdir cat ';' 2>/dev/null + [ "$BSD" ] || return 0 + # -okdir should *not* close stdin + yes | bfs_diff basic -okdir bash -c "printf '%s? ' {} && head -n1" \; 2>/dev/null } function test_0096() { diff --git a/tests/test_0094.out b/tests/test_0094.out new file mode 100644 index 0000000..30b57fd --- /dev/null +++ b/tests/test_0094.out @@ -0,0 +1,19 @@ +basic? y +basic/a? y +basic/b? y +basic/c? y +basic/e? y +basic/g? y +basic/i? y +basic/j? y +basic/k? y +basic/l? y +basic/c/d? y +basic/e/f? y +basic/g/h? y +basic/j/foo? y +basic/k/foo? y +basic/l/foo? y +basic/k/foo/bar? y +basic/l/foo/bar? y +basic/l/foo/bar/baz? y diff --git a/tests/test_0095.out b/tests/test_0095.out new file mode 100644 index 0000000..ef2a68b --- /dev/null +++ b/tests/test_0095.out @@ -0,0 +1,19 @@ +./a? y +./b? y +./bar? y +./bar? y +./basic? y +./baz? y +./c? y +./d? y +./e? y +./f? y +./foo? y +./foo? y +./foo? y +./g? y +./h? y +./i? y +./j? y +./k? y +./l? y -- cgit v1.2.3