Fix launch without any args

This commit is contained in:
Gregory 2020-05-18 21:59:40 -04:00
parent a791b6f016
commit e682e42bcb
No known key found for this signature in database
GPG key ID: 2E44FAEEDC94B1E2

View file

@ -114,16 +114,16 @@ impl DesktopEntry {
&self,
arg: Option<String>,
) -> Result<(String, Vec<String>)> {
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::<Vec<_>>();
let mut split = shlex::split(&replaced).ok_or(Error::BadCmd)?;
Ok((split.remove(0), split))
}
}