From 7083cfa8a7e9f89b1266e9b9a405f8f13ed99f3c Mon Sep 17 00:00:00 2001 From: Akshat Shukla <56386613+Nemesis-AS@users.noreply.github.com> Date: Mon, 27 Jul 2026 01:48:26 +0530 Subject: [PATCH] fix: fixed exec flag on windows(#1422) --- src/process.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/process.rs b/src/process.rs index b2b74ee8..b965cc12 100644 --- a/src/process.rs +++ b/src/process.rs @@ -3,7 +3,7 @@ use librespot_metadata::audio::AudioItem; use librespot_playback::player::PlayerEvent; use log::info; -use std::{collections::HashMap, process::Stdio}; +use std::{collections::HashMap, path::Path, process::Stdio}; use tokio::{ io::{self, AsyncWriteExt}, process::{self, Command}, @@ -11,12 +11,23 @@ use tokio::{ /// Spawns provided command in a subprocess using the provided shell. fn spawn_program(shell: &str, cmd: &str, env: HashMap<&str, String>) -> Result { + let exec_flag = match Path::new(shell) + .file_stem() + .and_then(|s| s.to_str()) + .map(|s| s.to_ascii_lowercase()) + .as_deref() + { + Some("cmd") => "/c", + Some("powershell") | Some("pwsh") => "-Command", + _ => "-c", + }; + info!( "Running {:?} using {:?} with environment variables {:?}", cmd, shell, env ); let inner = Command::new(shell) - .arg("-c") + .arg(exec_flag) .arg(cmd) .envs(env.iter()) .stdin(Stdio::piped())