diff options
| author | Jonas Maier <> | 2026-03-10 13:13:49 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-10 13:13:49 +0100 |
| commit | 7728b844958bb7882ddf384b40e5711d7a9316ad (patch) | |
| tree | fd8ecf5981da5cb317a2328265fad88a24b80093 /src/run | |
| parent | 961314b443849840e15d079ebd5724383489fd05 (diff) | |
| download | pish-7728b844958bb7882ddf384b40e5711d7a9316ad.tar.gz | |
completion if there is variables in the to-be-completed string
Diffstat (limited to 'src/run')
| -rw-r--r-- | src/run/mod.rs | 20 |
1 files changed, 19 insertions, 1 deletions
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<std::io::Error> for ExecError { pub struct Executor { se: Arc<Mutex<Session>>, args: Option<Vec<BString>>, + expand_commands: bool, } pub enum Input { @@ -172,6 +173,14 @@ impl SpawnedCmd { } impl Executor { + pub fn new_for_completion(se: Arc<Mutex<Session>>) -> 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<parse::PostExpansion>) -> Result<BString, Self::Error> { + 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<Mutex<Session>>, ast: Ast<PreExpansion>) -> 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) } |
