mirror of
https://github.com/fish-shell/fish-shell
synced 2025-02-13 12:43:43 +00:00
Also allow command and
in a pipeline
Similar to `time`, except that one is more common as a command.
Note that this will also allow `builtin and`, which is somewhat
useless, but then it is also useless outside of a pipeline.
Addition to #9985
(cherry picked from commit b454b3bc40
)
This commit is contained in:
parent
7815cb363c
commit
4d59d9cfb5
1 changed files with 16 additions and 16 deletions
|
@ -1155,23 +1155,23 @@ static bool detect_errors_in_decorated_statement(const wcstring &buff_src,
|
|||
// beginning. We can't disallow them as commands entirely because we need to support 'and
|
||||
// --help', etc.
|
||||
if (pipe_pos == pipeline_position_t::subsequent) {
|
||||
// check if our command is 'and' or 'or'. This is very clumsy; we don't catch e.g. quoted
|
||||
// commands.
|
||||
const wcstring &command = dst.command.source(buff_src, storage);
|
||||
if (command == L"and" || command == L"or") {
|
||||
errored = append_syntax_error(parse_errors, source_start, source_length,
|
||||
INVALID_PIPELINE_CMD_ERR_MSG, command.c_str());
|
||||
}
|
||||
// We only reject it if we have no decoration.
|
||||
// `echo foo | command time something`
|
||||
// is entirely fair and valid.
|
||||
// Other current decorations like "exec"
|
||||
// are already forbidden.
|
||||
const auto &deco = dst.decoration();
|
||||
if (deco == statement_decoration_t::none) {
|
||||
// check if our command is 'and' or 'or'. This is very clumsy; we don't catch e.g. quoted
|
||||
// commands.
|
||||
const wcstring &command = dst.command.source(buff_src, storage);
|
||||
if (command == L"and" || command == L"or") {
|
||||
errored = append_syntax_error(parse_errors, source_start, source_length,
|
||||
INVALID_PIPELINE_CMD_ERR_MSG, command.c_str());
|
||||
}
|
||||
|
||||
// Similarly for time (#8841).
|
||||
if (command == L"time") {
|
||||
// We only reject it if we have no decoration.
|
||||
// `echo foo | command time something`
|
||||
// is entirely fair and valid.
|
||||
// Other current decorations like "exec"
|
||||
// are already forbidden.
|
||||
const auto &deco = dst.decoration();
|
||||
if (deco == statement_decoration_t::none) {
|
||||
// Similarly for time (#8841).
|
||||
if (command == L"time") {
|
||||
errored = append_syntax_error(parse_errors, source_start, source_length,
|
||||
TIME_IN_PIPELINE_ERR_MSG);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue