From 9d66553443dce1ed70c3746178d1633c324f4951 Mon Sep 17 00:00:00 2001 From: SW Date: Mon, 15 Jun 2026 20:37:14 +0200 Subject: [PATCH] Quote custom commands in append mode to preserve shell operators --- src/custom.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custom.rs b/src/custom.rs index c455c83..82f02ef 100644 --- a/src/custom.rs +++ b/src/custom.rs @@ -18,7 +18,7 @@ pub fn build_commands(state: &CustomState) -> Vec { if command.contains("{}") { command.replace("{}", line) } else { - format!("{} {}", line, command) + format!("{} \"{}\"", line, command.replace('"', "\\\"")) } }) .collect() @@ -54,7 +54,7 @@ mod tests { ); assert_eq!( build_commands(&state), - vec!["ssh root@ip2 lsblk", "ssh root@ip3 lsblk"] + vec!["ssh root@ip2 \"lsblk\"", "ssh root@ip3 \"lsblk\""] ); }