Skip to content

Commit

Permalink
Wrap terminal commands in single quotation marks instead of backticks (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
bestgopher authored Sep 17, 2024
1 parent 4441150 commit 37b2f4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/terminal/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ fn task_summary(task: &TaskState, error_code: Option<i32>) -> (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)
}

Expand Down
8 changes: 4 additions & 4 deletions crates/terminal_view/src/terminal_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,22 +397,22 @@ 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")]
{
use crate::terminal_panel::WindowsShellType;

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)
}
}
}
Expand Down

0 comments on commit 37b2f4b

Please sign in to comment.