From 8aa9bce4adbb66aefff4992b3ee7ee1d02774339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Sun, 5 Feb 2023 19:02:05 +0000 Subject: [PATCH] try commands without args --- src/unix.rs | 18 ++++++++---------- src/windows.rs | 2 ++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/unix.rs b/src/unix.rs index 14bbca7..044b63f 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -11,17 +11,15 @@ use crate::{CommandExt, IntoResult}; pub fn command>(path: T) -> Command { let path = path.as_ref(); let open_handlers = [ - ("xdg-open", &["--version"], &[path] as &[_]), - ("gio", &["version"], &[OsStr::new("open"), path]), - ("gnome-open", &["--version"], &[path]), - ("kde-open", &["--version"], &[path]), - ("wslview", &["--version"], &[&wsl_path(path)]), + ("xdg-open", &[path] as &[_]), + ("gio", &[OsStr::new("open"), path]), + ("gnome-open", &[path]), + ("kde-open", &[path]), + ("wslview", &[&wsl_path(path)]), ]; - for (command, check_args, args) in &open_handlers { - let result = Command::new(command) - .args(*check_args) - .status_without_output(); + for (command, args) in &open_handlers { + let result = Command::new(command).status_without_output(); if let Ok(status) = result { if status.success() { @@ -33,7 +31,7 @@ pub fn command>(path: T) -> Command { } // fallback to xdg-open - let (command, _, args) = &open_handlers[0]; + let (command, args) = &open_handlers[0]; let mut cmd = Command::new(command); cmd.args(*args); cmd diff --git a/src/windows.rs b/src/windows.rs index 404c803..7d9cfa9 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,5 +1,7 @@ use std::{ffi::OsStr, io, process::Command}; +use crate::{CommandExt, IntoResult}; + pub fn command>(path: T) -> Command { let mut cmd = Command::new("cmd"); cmd.arg("/c").arg("start").arg(path.as_ref());