Don't leave is_block in bad state after bad redirection

Fixes #1728.
This commit is contained in:
Kevin Ballard 2014-09-30 17:06:56 -07:00
parent c181de1d7f
commit 51527612d3
7 changed files with 18 additions and 5 deletions

View file

@ -516,9 +516,6 @@ static void internal_exec_helper(parser_t &parser,
std::vector<int> 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)

View file

@ -1,4 +1,4 @@
#!/usr/bin/fish
#!/usr/bin/env fish
#
# Generate output for a test script

2
tests/status.err Normal file
View file

@ -0,0 +1,2 @@
fish: An error occurred while redirecting file '/'
open: Is a directory

9
tests/status.in Normal file
View file

@ -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

0
tests/status.out Normal file
View file

1
tests/status.status Normal file
View file

@ -0,0 +1 @@
0

View file

@ -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