From e682e42bcb06050a8cbfd6afccbcdd6843b95cce Mon Sep 17 00:00:00 2001 From: Gregory Date: Mon, 18 May 2020 21:59:40 -0400 Subject: [PATCH] Fix `launch` without any args --- src/common.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/common.rs b/src/common.rs index 29d8d38..95f20a5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -114,16 +114,16 @@ impl DesktopEntry { &self, arg: Option, ) -> Result<(String, Vec)> { - let arg = arg.unwrap_or_default(); - let arg = shlex::quote(&arg); - let replaced = self - .exec - .replace("%f", &arg) - .replace("%F", &arg) - .replace("%u", &arg) - .replace("%U", &arg); + let mut split = shlex::split(&self.exec) + .ok_or(Error::BadCmd)? + .into_iter() + .map(|s| match s.as_str() { + "%f" | "%F" | "%u" | "%U" => arg.clone(), + _ => Some(s), + }) + .filter_map(std::convert::identity) + .collect::>(); - let mut split = shlex::split(&replaced).ok_or(Error::BadCmd)?; Ok((split.remove(0), split)) } }