Added tests for piping an fd other than stdout

This commit is contained in:
ridiculousfish 2014-01-13 02:49:41 -08:00
parent 95f87cdd56
commit d9056081e7
3 changed files with 10 additions and 3 deletions

View file

@ -1011,7 +1011,7 @@ bool parse_execution_context_t::determine_io_chain(const parse_node_t &statement
if (old_fd < 0 || errno || *end)
{
errored = report_error(redirect_node,
_(L"Requested redirection to something that is not a file descriptor %ls"),
_(L"Requested redirection to '%ls', which is not a valid file descriptor"),
target.c_str());
}
else
@ -1186,7 +1186,7 @@ parse_execution_result_t parse_execution_context_t::populate_job_from_job_node(j
{
assert(job_cont->type == symbol_job_continuation);
/* Handle the pipe, whose fd may not be the obvious stdoud */
/* Handle the pipe, whose fd may not be the obvious stdout */
const parse_node_t &pipe_node = *get_child(*job_cont, 0, parse_token_type_pipe);
processes.back()->pipe_write_fd = fd_redirected_by_pipe(get_source(pipe_node));

View file

@ -15,7 +15,7 @@ echo x-{1}
echo x-{1,2}
echo foo-{1,2{3,4}}
# Escpaed newlines
# Escaped newlines
echo foo\ bar
echo foo\
bar
@ -99,6 +99,12 @@ echo Test 5 $sta
echo Test redirections
begin ; echo output ; echo errput 1>&2 ; end 2>&1 | tee /tmp/tee_test.txt ; cat /tmp/tee_test.txt
# Verify that we can pipe something other than stdout
# The first line should be printed, since we output to stdout but pipe stderr to /dev/null
# The second line should not be printed, since we output to stderr and pipe it to /dev/null
begin ; echo is_stdout ; end 2>| cat > /dev/null
begin ; echo is_stderr 1>&2 ; end 2>| cat > /dev/null
# echo tests
echo 'abc\ndef'

View file

@ -23,6 +23,7 @@ errput
output
errput
output
is_stdout
abc\ndef
abc
def