Remove ends_with_pipe from reader

Now that parse_util_detect_errors() can report incomplete pipelines,
we no longer have to detect this in the reader.
This commit is contained in:
ridiculousfish 2018-02-18 13:17:45 -08:00
parent ddd1afc57c
commit ea4e997dc9

View File

@ -302,7 +302,6 @@ static volatile sig_atomic_t interrupted = 0;
// Prototypes for a bunch of functions defined later on.
static bool is_backslashed(const wcstring &str, size_t pos);
static wchar_t unescaped_quote(const wcstring &str, size_t pos);
static bool ends_with_pipe(const wcstring &str, size_t pos);
/// Mode on startup, which we restore on exit.
static struct termios terminal_mode_on_startup;
@ -2303,19 +2302,6 @@ static bool is_backslashed(const wcstring &str, size_t pos) {
return (count % 2) == 1;
}
/// Test if the specified string ends with pipe. Whitespaces at the end are ignored. It returns
/// false if backslashed before the pipe because it should be treated as an escaped character.
static bool ends_with_pipe(const wcstring &str, size_t pos) {
if (pos > str.size()) return false;
while (pos--) {
wchar_t c = str.at(pos);
if (c == L'|') return !is_backslashed(str, pos);
if (!iswspace(c)) break;
}
return false;
}
static wchar_t unescaped_quote(const wcstring &str, size_t pos) {
wchar_t result = L'\0';
if (pos < str.size()) {
@ -2765,12 +2751,6 @@ const wchar_t *reader_readline(int nchars) {
insert_char(el, '\n');
break;
}
// A newline is inserted if the line ends with a pipe (issue #1285).
if (ends_with_pipe(el->text, el->size())) {
el->position = el->size();
insert_char(el, '\n');
break;
}
// See if this command is valid.
int command_test_result = data->test_func(el->text.c_str());