v0.3.0 : picoclaw en binaire 64-bit officiel (sipeed/picoclaw releases) + shims git en .cmd sur Windows (fini le batch renomme en .exe qui donnait Unsupported 16-Bit Application) avec routage via cmd.exe
This commit is contained in:
@@ -175,9 +175,26 @@ pub fn resolve_exec(
|
||||
args.extend(extra_args.iter().cloned());
|
||||
let mut env = agent.env.clone();
|
||||
env.extend(extra_env.clone());
|
||||
let (program, args) = route_cmd_script(program, args);
|
||||
Ok(ResolvedExec { program, args, env })
|
||||
}
|
||||
|
||||
/// On Windows, .cmd/.bat shims (git installs without a build step) must be
|
||||
/// executed through cmd.exe — spawning them directly fails.
|
||||
pub fn route_cmd_script(program: String, args: Vec<String>) -> (String, Vec<String>) {
|
||||
let lower = program.to_lowercase();
|
||||
if cfg!(windows) && (lower.ends_with(".cmd") || lower.ends_with(".bat")) {
|
||||
let shell = std::env::var_os("COMSPEC")
|
||||
.map(|s| s.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "cmd.exe".to_string());
|
||||
let mut full = vec!["/C".to_string(), program];
|
||||
full.extend(args);
|
||||
(shell, full)
|
||||
} else {
|
||||
(program, args)
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse --env KEY=VALUE entries.
|
||||
pub fn parse_env_list(items: &[String]) -> Result<BTreeMap<String, String>> {
|
||||
let mut map = BTreeMap::new();
|
||||
@@ -273,3 +290,33 @@ pub fn select_method<'a>(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn routes_cmd_scripts_through_comspec() {
|
||||
let (program, args) = route_cmd_script(
|
||||
"C:/x/agent.cmd".to_string(),
|
||||
vec!["--flag".to_string()],
|
||||
);
|
||||
let lower = program.to_lowercase();
|
||||
if cfg!(windows) {
|
||||
assert!(lower.ends_with("cmd.exe"), "{program}");
|
||||
assert_eq!(args[0], "/C");
|
||||
assert_eq!(args[1], "C:/x/agent.cmd");
|
||||
assert_eq!(args[2], "--flag");
|
||||
} else {
|
||||
assert_eq!(program, "C:/x/agent.cmd");
|
||||
assert_eq!(args, vec!["--flag".to_string()]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leaves_regular_programs_untouched() {
|
||||
let (program, args) = route_cmd_script("node".to_string(), vec!["-v".to_string()]);
|
||||
assert_eq!(program, "node");
|
||||
assert_eq!(args, vec!["-v".to_string()]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user