From 37b2f4b9d36a2a72fd2a1515bdc392cc6916c94b Mon Sep 17 00:00:00 2001 From: bestgopher <84328409@qq.com> Date: Tue, 17 Sep 2024 10:48:13 +0800 Subject: [PATCH] Wrap terminal commands in single quotation marks instead of backticks (#17637) before: ![image](https://github.com/user-attachments/assets/ffe8b036-297a-414e-92af-28a0230d3d25) after: ![image](https://github.com/user-attachments/assets/0cf22775-69ae-4320-b9bd-6b78fe01571f) Since I often copy the output commands to run in the command line, using backticks can cause errors because, in shell, backticks mean passing the execution result of the command inside them to the -c option. Therefore, I replace backticks with single quotes here. ![image](https://github.com/user-attachments/assets/f1f809fe-c10a-423a-87a2-58148962d8b0) Release Notes: - Fix display of task commands to not use backticks Signed-off-by: bestgopher <84328409@qq.com> --- crates/terminal/src/terminal.rs | 2 +- crates/terminal_view/src/terminal_panel.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index bd4dfed0fa..12a7349af0 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -1596,7 +1596,7 @@ fn task_summary(task: &TaskState, error_code: Option) -> (bool, String, Str } }; let escaped_command_label = task.command_label.replace("\r\n", "\r").replace('\n', "\r"); - let command_line = format!("{TASK_DELIMITER}Command: '{escaped_command_label}'"); + let command_line = format!("{TASK_DELIMITER}Command: {escaped_command_label}"); (success, task_line, command_line) } diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 1e8d09f0a6..f745fbe348 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -397,7 +397,7 @@ impl TerminalPanel { #[cfg(not(target_os = "windows"))] { - spawn_task.command_label = format!("{shell} -i -c `{}`", spawn_task.command_label); + spawn_task.command_label = format!("{shell} -i -c '{}'", spawn_task.command_label); } #[cfg(target_os = "windows")] { @@ -405,14 +405,14 @@ impl TerminalPanel { match windows_shell_type { WindowsShellType::Powershell => { - spawn_task.command_label = format!("{shell} -C `{}`", spawn_task.command_label) + spawn_task.command_label = format!("{shell} -C '{}'", spawn_task.command_label) } WindowsShellType::Cmd => { - spawn_task.command_label = format!("{shell} /C `{}`", spawn_task.command_label) + spawn_task.command_label = format!("{shell} /C '{}'", spawn_task.command_label) } WindowsShellType::Other => { spawn_task.command_label = - format!("{shell} -i -c `{}`", spawn_task.command_label) + format!("{shell} -i -c '{}'", spawn_task.command_label) } } }