aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse_util.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-02-13 10:08:04 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-02-13 10:10:49 -0800
commit1fbf63381782b0badead61d1576ad6a1e29fc3ea (patch)
tree778b1397a565f6cc214ae62ed6c15921d77d63b7 /parse_util.cpp
parentf733dc5eae81c092f74522f4e5cc7b3d27f2b943 (diff)
Reimplement exec parsing. Instead of special-casing exec as a command,
promote it to a decoration (like 'command' or 'builtin'). This makes tab completion and syntax highlighting treat exec's first argument as a command and is otherwise a nice simplification. Fixes #1300
Diffstat (limited to 'parse_util.cpp')
-rw-r--r--parse_util.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/parse_util.cpp b/parse_util.cpp
index 68f65248..230a328c 100644
--- a/parse_util.cpp
+++ b/parse_util.cpp
@@ -1067,6 +1067,15 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, pars
}
else if (node.type == symbol_plain_statement)
{
+ // In a few places below, we want to know if we are in a pipeline
+ const bool is_in_pipeline = node_tree.statement_is_in_pipeline(node, true /* count first */);
+
+ // Check that we don't try to pipe through exec
+ if (is_in_pipeline && node_tree.decoration_for_plain_statement(node) == parse_statement_decoration_exec)
+ {
+ errored = append_syntax_error(&parse_errors, node, EXEC_ERR_MSG, L"exec");
+ }
+
wcstring command;
if (node_tree.command_for_plain_statement(node, buff_src, &command))
{
@@ -1077,13 +1086,9 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, pars
}
// Check that pipes are sound
- if (! errored && parser_is_pipe_forbidden(command))
+ if (! errored && parser_is_pipe_forbidden(command) && is_in_pipeline)
{
- // forbidden commands cannot be in a pipeline at all
- if (node_tree.statement_is_in_pipeline(node, true /* count first */))
- {
- errored = append_syntax_error(&parse_errors, node, EXEC_ERR_MSG, command.c_str());
- }
+ errored = append_syntax_error(&parse_errors, node, EXEC_ERR_MSG, command.c_str());
}
// Check that we don't return from outside a function