From 1d73e2c9cd196b6bbcda085e4db5ca25d615fb47 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 17 Jan 2022 17:06:08 -0500 Subject: simplify --- src/parse/ast.rs | 9 +++------ 1 file 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) -> 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(), )], }, ], -- cgit v1.2.3-54-g00ecf