From 7f905b082d7d427c04ccc54df9f242f6f94d4b4d Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 8 Apr 2022 17:07:47 +0200 Subject: [PATCH] Remove caret redirection code It's dead, Jim. --- src/common.cpp | 4 +--- src/fish_tests.cpp | 10 ---------- src/tokenizer.cpp | 30 +----------------------------- 3 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 95a81657b..c80451eef 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -885,7 +885,6 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring const bool escape_all = static_cast(flags & ESCAPE_ALL); const bool no_quoted = static_cast(flags & ESCAPE_NO_QUOTED); const bool no_tilde = static_cast(flags & ESCAPE_NO_TILDE); - const bool no_caret = feature_test(features_t::stderr_nocaret); const bool no_qmark = feature_test(features_t::qmark_noglob); bool need_escape = false; @@ -977,7 +976,6 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring case L'$': case L' ': case L'#': - case L'^': case L'<': case L'>': case L'(': @@ -993,7 +991,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring case L'"': case L'%': case L'~': { - bool char_is_normal = (c == L'~' && no_tilde) || (c == L'^' && no_caret) || + bool char_is_normal = (c == L'~' && no_tilde) || (c == L'?' && no_qmark); if (!char_is_normal) { need_escape = true; diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 688205132..730cbde5c 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -786,16 +786,6 @@ static void test_tokenizer() { err(L"redirection_type_for_string failed on line %ld", (long)__LINE__); if (get_redir_mode(L"3 token_length) { @@ -118,10 +115,6 @@ static bool tok_is_string_character(wchar_t c, bool is_first, maybe_t n // Unlike in other shells, '&' is not special if followed by a string character. return next_is_string; } - case L'^': { - // Conditional separator. - return !caret_redirs() || !is_first; - } default: { return true; } @@ -436,27 +429,6 @@ maybe_t pipe_or_redir_t::from_string(const wchar_t *buff) { : STDIN_FILENO; // like <&3 or < /tmp/file.txt break; } - case L'^': { - if (!caret_redirs()) { - // ^ is not special if caret_redirs is disabled. - return none(); - } else { - if (has_fd) { - return none(); - } - consume(L'^'); - result.fd = STDERR_FILENO; - result.mode = redirection_mode_t::overwrite; - 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; - } - } case L'&': { consume(L'&'); if (try_consume(L'|')) { @@ -655,7 +627,7 @@ maybe_t tokenizer_t::next() { // Maybe a redirection like '2>&1', maybe a pipe like 2>|, maybe just a string. const wchar_t *error_location = this->token_cursor; maybe_t redir_or_pipe{}; - if (iswdigit(*this->token_cursor) || (*this->token_cursor == L'^' && caret_redirs())) { + if (iswdigit(*this->token_cursor)) { redir_or_pipe = pipe_or_redir_t::from_string(this->token_cursor); }