From 2d49c5932b8885a74fb3f3344e49626f82d2da21 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy <mmstickman@gmail.com> Date: Wed, 1 Nov 2017 15:42:16 -0400 Subject: [PATCH] Empty Arguments = No Arg When expanding arguments, if an argument evaluates to an empty argument, simply ignore the argument as if it didn't exist. --- src/shell/job.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/shell/job.rs b/src/shell/job.rs index 32ed824f..e3cad8c2 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; } } -- GitLab