From cc2cfa730af4c5b512f32418451e2768683226ee Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 9 Jun 2017 17:12:24 +0200 Subject: [PATCH] parser: implement |& as a shortcut for 2>&1| --- parser.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/parser.c b/parser.c index 1e07fb4f..5f008287 100644 --- a/parser.c +++ b/parser.c @@ -1044,6 +1044,25 @@ command_T *parse_commands_in_pipeline(parsestate_T *ps) if (ps->src.contents[ps->index] == L'|' && ps->src.contents[ps->index + 1] != L'|') { ps->index++; + if (ps->src.contents[ps->index] == '&') { /* parse |& as 2>&1| */ + ps->index++; + + wordunit_T *w = xmalloc(sizeof *w); + w->next = NULL; + w->wu_type = WT_STRING; + w->wu_string = xwcsndup(L"1", 1); + + redir_T *redir = xmalloc(sizeof *redir); + redir->next = NULL; + redir->rd_fd = 2; + redir->rd_type = RT_DUPOUT; + redir->rd_filename = w; + + redir_T **r = &c->c_redirs; + while (*r != NULL) + r = &(*r)->next; + *r = redir; + } } else { break; } -- 2.13.1