From 7a7050162c19192755ab27278bff5d70b89cbdca Mon Sep 17 00:00:00 2001 From: prjanitor Date: Wed, 1 Apr 2026 11:36:44 +0300 Subject: [PATCH] Fix panic on empty process vector in pipeline evaluation Add a check for empty a_procs before calling .last_mut().unwrap() in the Pipeline case of eval_command. When the left side of a pipeline produces no processes (e.g., due to an error in execute_simple_command), the previous code would panic at runtime. Now it returns early with an empty result. --- crates/tgs_lexer/src/eval.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/tgs_lexer/src/eval.rs b/crates/tgs_lexer/src/eval.rs index 6899675..1e1ccff 100644 --- a/crates/tgs_lexer/src/eval.rs +++ b/crates/tgs_lexer/src/eval.rs @@ -73,6 +73,9 @@ pub fn eval_command( ast::Command::Pipeline(a_cmd, b_cmd) => { let (mut a_procs, _a_pgid) = eval_command(job_manager, a_cmd, stdin, Some(Output::CreatePipe))?; + if a_procs.is_empty() { + return Ok((vec![], None)); + } let (b_procs, b_pgid) = eval_command( job_manager, b_cmd,