From 7728b844958bb7882ddf384b40e5711d7a9316ad Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Tue, 10 Mar 2026 13:13:49 +0100 Subject: completion if there is variables in the to-be-completed string --- src/run/mod.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/run/mod.rs') diff --git a/src/run/mod.rs b/src/run/mod.rs index 757f4cc..5a8370f 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -83,6 +83,7 @@ impl From for ExecError { pub struct Executor { se: Arc>, args: Option>, + expand_commands: bool, } pub enum Input { @@ -172,6 +173,14 @@ impl SpawnedCmd { } impl Executor { + pub fn new_for_completion(se: Arc>) -> Self { + Self { + se, + args: None, + expand_commands: false, + } + } + fn spawn_cmd( &mut self, cmd: CommandKind, @@ -310,6 +319,7 @@ impl Executor { let mut this = Self { se: session, args: None, + expand_commands: true, }; let cmd = parse::Command { @@ -362,6 +372,10 @@ impl parse::Expander for Executor { } fn expand_cmd(&mut self, ast: Ast) -> Result { + if !self.expand_commands { + return Err(ExecError::ExecError(-1)); + } + let (stdin, _) = io::pipe().unwrap(); let (mut expansion, stdout) = io::pipe().unwrap(); let mut this = self.clone(); @@ -378,7 +392,11 @@ impl parse::Expander for Executor { } fn exec(se: Arc>, ast: Ast) -> Result<(), ExecError> { - let mut exec = Executor { se, args: None }; + let mut exec = Executor { + se, + args: None, + expand_commands: true, + }; let ast = ast.expand(&mut exec)?; exec.execute(ast, Input::Stdin, Output::Stdout) } -- cgit v1.2.3