Skip to content

Commit 8f0bb34

Browse files
committed
Improve command formatting
1 parent 67e18c6 commit 8f0bb34

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/utils.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,16 @@ fn rem_first_and_last(value: &str) -> &str {
5757
}
5858

5959
fn fmt_command(command: &Command) -> String {
60-
let cmd_str_raw = format!("{:?}", command).split("\" \"").join(" ");
60+
let cmd_str_raw = format!("{:?}", command)
61+
.split("\" \"")
62+
.map(|s| {
63+
if s.contains('?') || s.contains('!') {
64+
format!("'{}'", s.replace('\'', "\\'"))
65+
} else {
66+
s.to_string()
67+
}
68+
})
69+
.join(" ");
6170
rem_first_and_last(&cmd_str_raw).to_string()
6271
}
6372

0 commit comments

Comments
 (0)