From aa5f0f5745e4e7392c078d1fe28825c941f52f7c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 31 Jan 2019 23:46:56 -0500 Subject: main: Fix closed standard stream handling bfs >&- should complain about a missing file descriptor, rather than silently succeeding. --- tests.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests.sh') diff --git a/tests.sh b/tests.sh index 775a254..302a4c2 100755 --- a/tests.sh +++ b/tests.sh @@ -290,6 +290,11 @@ posix_tests=( test_user_name test_user_id + # Closed file descriptors + test_closed_stdin + test_closed_stdout + test_closed_stderr + # PATH_MAX handling test_deep @@ -385,8 +390,10 @@ bsd_tests=( test_nouser test_ok_stdin + test_ok_closed_stdin test_okdir_stdin + test_okdir_closed_stdin test_perm_000_plus test_perm_222_plus @@ -525,8 +532,10 @@ gnu_tests=( test_nouser + test_ok_closed_stdin test_ok_nothing + test_okdir_closed_stdin test_okdir_plus_semicolon test_perm_000_slash @@ -1929,6 +1938,26 @@ function test_fprint_error() { fi } +function test_closed_stdin() { + bfs_diff basic <&- +} + +function test_ok_closed_stdin() { + bfs_diff basic -ok echo \; <&- 2>/dev/null +} + +function test_okdir_closed_stdin() { + bfs_diff basic -okdir echo {} \; <&- 2>/dev/null +} + +function test_closed_stdout() { + ! invoke_bfs basic >&- 2>/dev/null +} + +function test_closed_stderr() { + ! invoke_bfs basic >&- 2>&- +} + if [ -t 1 -a ! "$VERBOSE" ]; then in_place=yes fi -- cgit v1.2.3