terminal: Fix escaping arguments when using CMD as the shell (#39701)
A couple of caveats: - We should not auto-escape arguments with Alacritty's `escape_args` option if using CMD otherwise, the generated command will have way too many escaped characters for CMD to parse correctly. - When composing a full command for CMD, we need to put it in double quotes manually: `cmd /C "activate.bat& pwsh.exe -C do_something"` so that CMD executes the entire string as a sequence of commands. - CMD requires `&` as a chaining operator for commands (`;` for other shells). Release Notes: - N/A
This commit is contained in:
@@ -1180,15 +1180,7 @@ impl ToolchainLister for PythonToolchainProvider {
|
||||
}
|
||||
Some(PythonEnvironmentKind::Venv | PythonEnvironmentKind::VirtualEnv) => {
|
||||
if let Some(prefix) = &toolchain.prefix {
|
||||
let activate_keyword = match shell {
|
||||
ShellKind::Cmd => ".",
|
||||
ShellKind::Nushell => "overlay use",
|
||||
ShellKind::PowerShell => ".",
|
||||
ShellKind::Fish => "source",
|
||||
ShellKind::Csh => "source",
|
||||
ShellKind::Tcsh => "source",
|
||||
ShellKind::Posix | ShellKind::Rc => "source",
|
||||
};
|
||||
let activate_keyword = shell.activate_keyword();
|
||||
let activate_script_name = match shell {
|
||||
ShellKind::Posix | ShellKind::Rc => "activate",
|
||||
ShellKind::Csh => "activate.csh",
|
||||
@@ -1200,8 +1192,7 @@ impl ToolchainLister for PythonToolchainProvider {
|
||||
};
|
||||
let path = prefix.join(BINARY_DIR).join(activate_script_name);
|
||||
|
||||
if let Ok(quoted) =
|
||||
shlex::try_quote(&path.to_string_lossy()).map(Cow::into_owned)
|
||||
if let Some(quoted) = shell.try_quote(&path.to_string_lossy())
|
||||
&& fs.is_file(&path).await
|
||||
{
|
||||
activation_script.push(format!("{activate_keyword} {quoted}"));
|
||||
|
||||
Reference in New Issue
Block a user