diff --git a/exec.cpp b/exec.cpp index 60b46ab9a..e282f72fb 100644 --- a/exec.cpp +++ b/exec.cpp @@ -516,9 +516,6 @@ static void internal_exec_helper(parser_t &parser, std::vector opened_fds; bool transmorgrified = io_transmogrify(ios, &morphed_chain, &opened_fds); - int is_block_old=is_block; - is_block=1; - /* Did the transmogrification fail - if so, set error status and return */ @@ -528,6 +525,9 @@ static void internal_exec_helper(parser_t &parser, return; } + int is_block_old=is_block; + is_block=1; + signal_unblock(); if (node_offset == NODE_OFFSET_INVALID) diff --git a/tests/gen_output.fish b/tests/gen_output.fish index 49e15bfdc..7bf7f3ec3 100755 --- a/tests/gen_output.fish +++ b/tests/gen_output.fish @@ -1,4 +1,4 @@ -#!/usr/bin/fish +#!/usr/bin/env fish # # Generate output for a test script @@ -14,4 +14,4 @@ for i in $argv fish <$i >$template_out ^$template_err echo $status >$template_status -end \ No newline at end of file +end diff --git a/tests/status.err b/tests/status.err new file mode 100644 index 000000000..91645c95f --- /dev/null +++ b/tests/status.err @@ -0,0 +1,2 @@ +fish: An error occurred while redirecting file '/' +open: Is a directory diff --git a/tests/status.in b/tests/status.in new file mode 100644 index 000000000..14dff2320 --- /dev/null +++ b/tests/status.in @@ -0,0 +1,9 @@ +# vim: set filetype=fish: + +# Issue #1728 +# Bad file redirection on a block causes `status --is-block` to return 0 forever. +begin; end >/ # / is a directory, it can't be opened for writing +status -b +and echo 'block' + +true diff --git a/tests/status.out b/tests/status.out new file mode 100644 index 000000000..e69de29bb diff --git a/tests/status.status b/tests/status.status new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/status.status @@ -0,0 +1 @@ +0 diff --git a/tests/top.out b/tests/top.out index a62ec0474..87d1ee313 100644 --- a/tests/top.out +++ b/tests/top.out @@ -2,6 +2,7 @@ Testing high level script functionality File expansion.in tested ok File printf.in tested ok File read.in tested ok +File status.in tested ok File test1.in tested ok File test2.in tested ok File test3.in tested ok