diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index c55fb0bdc..119f325a3 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -332,8 +332,12 @@ fn push_token_to_either_stack( } Token::PrefixOp { .. } | Token::ParOpen => { - op_stack.push((token_idx, token.clone())); - Ok(()) + if out_stack.is_empty() { + op_stack.push((token_idx, token.clone())); + Ok(()) + } else { + Err(String::from("syntax error (operation should be prefix)")) + } } Token::ParClose => move_till_match_paren(out_stack, op_stack),