diff --git a/src/shell/job.rs b/src/shell/job.rs index 32ed824ffcc1bab114ca38895f973dc23368ca55..e3cad8c27082ab5cb1408d6d135126626c22c48b 100644 --- a/src/shell/job.rs +++ b/src/shell/job.rs @@ -42,14 +42,19 @@ impl Job { pub(crate) fn expand(&mut self, shell: &Shell) { let mut expanded = Array::new(); expanded.grow(self.args.len()); - expanded.extend(self.args.drain().flat_map(|arg| match arg.as_str() { - "!!" => expand_last_command(shell, Operation::All), - "!$" => expand_last_command(shell, Operation::LastArg), - "!0" => expand_last_command(shell, Operation::Command), - "!^" => expand_last_command(shell, Operation::FirstArg), - "!*" => expand_last_command(shell, Operation::NoCommand), - _ => expand_arg(&arg, shell), - })); + expanded.extend( + self.args + .drain() + .flat_map(|arg| match arg.as_str() { + "!!" => expand_last_command(shell, Operation::All), + "!$" => expand_last_command(shell, Operation::LastArg), + "!0" => expand_last_command(shell, Operation::Command), + "!^" => expand_last_command(shell, Operation::FirstArg), + "!*" => expand_last_command(shell, Operation::NoCommand), + _ => expand_arg(&arg, shell), + }) + .filter(|x| !x.is_empty()), + ); self.args = expanded; } }