aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-13 02:49:41 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-01-13 02:49:41 -0800
commitd9056081e78cc847574589d8ca31f2e25a82b6f5 (patch)
tree502538a6c2b6e1e032ee3a5c49dce6de55c14691
parent95f87cdd56602fe7c2746519f875741c325d2df8 (diff)
Added tests for piping an fd other than stdout
-rw-r--r--parse_execution.cpp4
-rw-r--r--tests/test1.in8
-rw-r--r--tests/test1.out1
3 files changed, 10 insertions, 3 deletions
diff --git a/parse_execution.cpp b/parse_execution.cpp
index 70454d15..cc0a4ddd 100644
--- a/parse_execution.cpp
+++ b/parse_execution.cpp
@@ -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));
diff --git a/tests/test1.in b/tests/test1.in
index c180159c..7f60a4da 100644
--- a/tests/test1.in
+++ b/tests/test1.in
@@ -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'
diff --git a/tests/test1.out b/tests/test1.out
index c6ecbb30..b3460cdd 100644
--- a/tests/test1.out
+++ b/tests/test1.out
@@ -23,6 +23,7 @@ errput
output
errput
output
+is_stdout
abc\ndef
abc
def