From 3a7719015d1c33f326b613449957a54855c939de Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 12 Jun 2016 02:16:46 -0700 Subject: Don't allow specifying an fd with a caret redirection For example, an argument 12345^ is a real argument, not a redirection There's no reason to use ^ here instead of >, and it's annoying to git users. Fixes #1873 --- src/tokenizer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 7357fd35..8e0bc590 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -383,10 +383,11 @@ static size_t read_redirection_or_fd_pipe(const wchar_t *buff, } } } - + // Either way we should have ended on the redirection character itself like '>'. + // Don't allow an fd with a caret redirection - see #1873 wchar_t redirect_char = buff[idx++]; // note increment of idx - if (redirect_char == L'>' || redirect_char == L'^') { + if (redirect_char == L'>' || (redirect_char == L'^' && idx == 1)) { redirection_mode = TOK_REDIRECT_OUT; if (buff[idx] == redirect_char) { // Doubled up like ^^ or >>. That means append. -- cgit v1.2.3