Use ShellKind::try_quote whenever we need to quote shell args (#41104)
Re-reverts https://github.com/zed-industries/zed/commit/8f4646d6c357409cfc286104088b4d21f2bea851 with fixes Release Notes: - N/A
This commit is contained in:
@@ -4,7 +4,7 @@ use language::Buffer;
|
||||
use remote::RemoteClient;
|
||||
use rpc::proto::{self, REMOTE_SERVER_PROJECT_ID};
|
||||
use std::{collections::VecDeque, path::Path, sync::Arc};
|
||||
use task::Shell;
|
||||
use task::{Shell, shell_to_proto};
|
||||
use util::ResultExt;
|
||||
use worktree::Worktree;
|
||||
|
||||
@@ -198,7 +198,7 @@ impl ProjectEnvironment {
|
||||
.proto_client()
|
||||
.request(proto::GetDirectoryEnvironment {
|
||||
project_id: REMOTE_SERVER_PROJECT_ID,
|
||||
shell: Some(shell.clone().to_proto()),
|
||||
shell: Some(shell_to_proto(shell.clone())),
|
||||
directory: abs_path.to_string_lossy().to_string(),
|
||||
});
|
||||
cx.spawn(async move |_, _| {
|
||||
|
||||
@@ -657,6 +657,7 @@ impl LspCommand for GetLspRunnables {
|
||||
);
|
||||
task_template.args.extend(cargo.cargo_args);
|
||||
if !cargo.executable_args.is_empty() {
|
||||
let shell_kind = task_template.shell.shell_kind(cfg!(windows));
|
||||
task_template.args.push("--".to_string());
|
||||
task_template.args.extend(
|
||||
cargo
|
||||
@@ -682,7 +683,7 @@ impl LspCommand for GetLspRunnables {
|
||||
// That bit is not auto-expanded when using single quotes.
|
||||
// Escape extra cargo args unconditionally as those are unlikely to contain `~`.
|
||||
.flat_map(|extra_arg| {
|
||||
shlex::try_quote(&extra_arg).ok().map(|s| s.to_string())
|
||||
shell_kind.try_quote(&extra_arg).map(|s| s.to_string())
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -167,18 +167,19 @@ impl Project {
|
||||
match remote_client {
|
||||
Some(remote_client) => match activation_script.clone() {
|
||||
activation_script if !activation_script.is_empty() => {
|
||||
let activation_script = activation_script.join("; ");
|
||||
let separator = shell_kind.sequential_commands_separator();
|
||||
let activation_script =
|
||||
activation_script.join(&format!("{separator} "));
|
||||
let to_run = format_to_run();
|
||||
let args =
|
||||
vec!["-c".to_owned(), format!("{activation_script}; {to_run}")];
|
||||
let shell = remote_client
|
||||
.read(cx)
|
||||
.shell()
|
||||
.unwrap_or_else(get_default_system_shell);
|
||||
let arg = format!("{activation_script}{separator} {to_run}");
|
||||
let args = shell_kind.args_for_shell(false, arg);
|
||||
|
||||
create_remote_shell(
|
||||
Some((
|
||||
&remote_client
|
||||
.read(cx)
|
||||
.shell()
|
||||
.unwrap_or_else(get_default_system_shell),
|
||||
&args,
|
||||
)),
|
||||
Some((&shell, &args)),
|
||||
env,
|
||||
path,
|
||||
remote_client,
|
||||
@@ -547,7 +548,7 @@ fn create_remote_shell(
|
||||
Shell::WithArguments {
|
||||
program: command.program,
|
||||
args: command.args,
|
||||
title_override: Some(format!("{} — Terminal", host).into()),
|
||||
title_override: Some(format!("{} — Terminal", host)),
|
||||
},
|
||||
command.env,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user