fix(windows): use cmd on windows instead of sh (#102)

Co-authored-by: liyixin <root@liyixin-test.sci-inv.cn>
This commit is contained in:
liyixin 2024-12-06 17:37:44 +08:00 committed by GitHub
parent 4567f26a37
commit f9d33e4797
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 4 deletions

View File

@ -5,6 +5,7 @@ use television_fuzzy::{
matcher::{config::Config, injector::Injector},
Matcher,
};
use television_utils::command::shell_command;
#[allow(dead_code)]
pub struct Channel {
@ -57,8 +58,7 @@ impl Channel {
#[allow(clippy::unused_async)]
async fn load_candidates(command: String, injector: Injector<String>) {
let output = std::process::Command::new("sh")
.arg("-c")
let output = shell_command()
.arg(command)
.output()
.expect("failed to execute process");

View File

@ -8,6 +8,7 @@ use std::collections::HashSet;
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::Arc;
use television_channels::entry::{Entry, PreviewCommand};
use television_utils::command::shell_command;
use tracing::debug;
#[allow(dead_code)]
@ -151,8 +152,7 @@ pub fn try_preview(
let command = format_command(command, entry);
debug!("Formatted preview command: {:?}", command);
let output = std::process::Command::new("sh")
.arg("-c")
let output = shell_command()
.arg(&command)
.output()
.expect("failed to execute process");

View File

@ -0,0 +1,19 @@
use std::process::Command;
#[cfg(not(windows))]
pub fn shell_command() -> Command {
let mut cmd = Command::new("sh");
cmd.arg("-c");
cmd
}
#[cfg(windows)]
pub fn shell_command() -> Command {
let mut cmd = Command::new("cmd");
cmd.arg("/c");
cmd
}

View File

@ -1,4 +1,5 @@
pub mod cache;
pub mod command;
pub mod files;
pub mod indices;
pub mod stdin;