From eea919f97ee2956f7fa55c9e6d00dc97369db89b Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 14 Feb 2020 20:27:30 +0100 Subject: [PATCH] Readd `^&1` redirection This was lost in 35671dd9f094cf8c643c9cf224c27a2b55578937. Even tho we plan to drop caret redirection, while it's there it should fully work. Fixes #6591. (cherry picked from commit 13b470af0756dcdacaeee8a69426e1ac8c26ebbb) --- src/tokenizer.cpp | 7 ++++++- tests/checks/features-nocaret5.fish | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/checks/features-nocaret5.fish diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 872518be7..d568e81bd 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -412,7 +412,12 @@ maybe_t pipe_or_redir_t::from_string(const wchar_t *buff) { consume(L'^'); result.fd = STDERR_FILENO; result.mode = redirection_mode_t::overwrite; - if (try_consume(L'^')) result.mode = redirection_mode_t::append; + if (try_consume(L'^')) { + result.mode = redirection_mode_t::append; + } else if (try_consume(L'&')) { + // This is a redirection to an fd. + result.mode = redirection_mode_t::fd; + } if (try_consume(L'?')) result.mode = redirection_mode_t::noclob; break; } diff --git a/tests/checks/features-nocaret5.fish b/tests/checks/features-nocaret5.fish new file mode 100644 index 000000000..0dc3c25f6 --- /dev/null +++ b/tests/checks/features-nocaret5.fish @@ -0,0 +1,2 @@ +#RUN: %fish --features no-stderr-nocaret -c 'ls /abavojijsdfhdsjhfuihifoisj ^&1' +# CHECK: ls: {{.*}}