mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Added tests for piping an fd other than stdout
This commit is contained in:
parent
95f87cdd56
commit
d9056081e7
@ -1011,7 +1011,7 @@ bool parse_execution_context_t::determine_io_chain(const parse_node_t &statement
|
|||||||
if (old_fd < 0 || errno || *end)
|
if (old_fd < 0 || errno || *end)
|
||||||
{
|
{
|
||||||
errored = report_error(redirect_node,
|
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());
|
target.c_str());
|
||||||
}
|
}
|
||||||
else
|
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);
|
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);
|
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));
|
processes.back()->pipe_write_fd = fd_redirected_by_pipe(get_source(pipe_node));
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ echo x-{1}
|
|||||||
echo x-{1,2}
|
echo x-{1,2}
|
||||||
echo foo-{1,2{3,4}}
|
echo foo-{1,2{3,4}}
|
||||||
|
|
||||||
# Escpaed newlines
|
# Escaped newlines
|
||||||
echo foo\ bar
|
echo foo\ bar
|
||||||
echo foo\
|
echo foo\
|
||||||
bar
|
bar
|
||||||
@ -99,6 +99,12 @@ echo Test 5 $sta
|
|||||||
echo Test redirections
|
echo Test redirections
|
||||||
begin ; echo output ; echo errput 1>&2 ; end 2>&1 | tee /tmp/tee_test.txt ; cat /tmp/tee_test.txt
|
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 tests
|
||||||
|
|
||||||
echo 'abc\ndef'
|
echo 'abc\ndef'
|
||||||
|
@ -23,6 +23,7 @@ errput
|
|||||||
output
|
output
|
||||||
errput
|
errput
|
||||||
output
|
output
|
||||||
|
is_stdout
|
||||||
abc\ndef
|
abc\ndef
|
||||||
abc
|
abc
|
||||||
def
|
def
|
||||||
|
Loading…
x
Reference in New Issue
Block a user