summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-17 17:06:08 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-17 17:06:08 -0500
commit1d73e2c9cd196b6bbcda085e4db5ca25d615fb47 (patch)
tree5c66e34810b37ff620bb5212188e1c8b708bd5e8
parentcbcb6eb53ee65710657b2e058d2bfe8c5837a96d (diff)
downloadnbsh-1d73e2c9cd196b6bbcda085e4db5ca25d615fb47.tar.gz
nbsh-1d73e2c9cd196b6bbcda085e4db5ca25d615fb47.zip
simplify
-rw-r--r--src/parse/ast.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/parse/ast.rs b/src/parse/ast.rs
index 534c87e..089c9f8 100644
--- a/src/parse/ast.rs
+++ b/src/parse/ast.rs
@@ -147,6 +147,8 @@ impl Exe {
fn build_ast(pair: pest::iterators::Pair<Rule>) -> Self {
assert!(matches!(pair.as_rule(), Rule::subshell | Rule::exe));
if matches!(pair.as_rule(), Rule::subshell) {
+ let commands = pair.into_inner().next().unwrap();
+ assert!(matches!(commands.as_rule(), Rule::commands));
return Self {
exe: Word {
parts: vec![WordPart::SingleQuoted(
@@ -163,12 +165,7 @@ impl Exe {
},
Word {
parts: vec![WordPart::SingleQuoted(
- pair.as_str()
- .strip_prefix('(')
- .unwrap()
- .strip_suffix(')')
- .unwrap()
- .to_string(),
+ commands.as_str().to_string(),
)],
},
],