Closed zjp-CN closed 1 month ago
To parse as a Grouping
, you need to enclose the commands in braces:
let cmd = r#"{ cargo fmt; echo 1; }"#;
Thanks! It works well.
Though I made a mistake after seeing your revised cmd string 🥲
let cmd = r#"{cargo fmt; echo 1; }"#; // mistake on left brace without a whitespace
let ast: CompoundCommand = cmd.parse().unwrap(); // error: called `Result::unwrap()` on an `Err` value: None
If it's parsed to CompoundCommand, then the error is
called `Result::unwrap()` on an `Err` value: None
.I thought the cmd string could be parsed as CompoundCommand::Grouping variant to be CompoundCommand and Command.