fixed empty arguments being filtered out during word splitting

This commit is contained in:
2026-02-16 19:09:10 -05:00
parent 142194c100
commit 12f36283ca
4 changed files with 16 additions and 12 deletions

View File

@@ -94,9 +94,7 @@ impl Expander {
_ => cur_word.push(ch),
}
}
if !cur_word.is_empty() {
words.push(cur_word);
}
words.push(cur_word);
words
}
}
@@ -754,7 +752,7 @@ pub fn expand_proc_sub(raw: &str, is_input: bool) -> ShResult<String> {
let mut io_stack = IoStack::new();
io_stack.push_frame(io_frame);
if let Err(e) = exec_input(raw.to_string(), Some(io_stack)) {
if let Err(e) = exec_input(raw.to_string(), Some(io_stack), false) {
eprintln!("{e}");
exit(1);
}
@@ -787,7 +785,7 @@ pub fn expand_cmd_sub(raw: &str) -> ShResult<String> {
match unsafe { fork()? } {
ForkResult::Child => {
io_stack.push_frame(cmd_sub_io_frame);
if let Err(e) = exec_input(raw.to_string(), Some(io_stack)) {
if let Err(e) = exec_input(raw.to_string(), Some(io_stack), false) {
eprintln!("{e}");
unsafe { libc::_exit(1) };
}