Remove caret redirection code

It's dead, Jim.
This commit is contained in:
Fabian Homborg 2022-04-08 17:07:47 +02:00 committed by Fabian Boehm
parent 74be3e847f
commit 7f905b082d
3 changed files with 2 additions and 42 deletions

View file

@ -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<bool>(flags & ESCAPE_ALL);
const bool no_quoted = static_cast<bool>(flags & ESCAPE_NO_QUOTED);
const bool no_tilde = static_cast<bool>(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;

View file

@ -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</tmp/filetxt") != redirection_mode_t::input)
err(L"redirection_type_for_string failed on line %ld", (long)__LINE__);
// Test ^ with our feature flag on and off.
auto saved_flags = fish_features();
mutable_fish_features().set(features_t::stderr_nocaret, false);
if (get_redir_mode(L"^") != redirection_mode_t::overwrite)
err(L"redirection_type_for_string failed on line %ld", (long)__LINE__);
mutable_fish_features().set(features_t::stderr_nocaret, true);
if (get_redir_mode(L"^") != none())
err(L"redirection_type_for_string failed on line %ld", (long)__LINE__);
mutable_fish_features() = saved_flags;
}
// Little function that runs in a background thread, bouncing to the main.

View file

@ -55,9 +55,6 @@ const wchar_t *tokenizer_get_error_message(tokenizer_error_t err) {
return nullptr;
}
// Whether carets redirect stderr.
static bool caret_redirs() { return !feature_test(features_t::stderr_nocaret); }
/// Return an error token and mark that we no longer have a next token.
tok_t tokenizer_t::call_error(tokenizer_error_t error_type, const wchar_t *token_start,
const wchar_t *error_loc, maybe_t<size_t> token_length) {
@ -118,10 +115,6 @@ static bool tok_is_string_character(wchar_t c, bool is_first, maybe_t<wchar_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> 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<tok_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<pipe_or_redir_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);
}