From e21151b5d04cf7d6501ffb954a2fc8cd8db74a31 Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Wed, 7 Jun 2023 22:43:15 +0100 Subject: [PATCH] Bit of a hack to get shell escape working --- Cargo.toml | 1 - src/main.rs | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 45b5c9d..35923ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,4 @@ native-dialog = "0.6.3" rfd = "0.11.4" serde = "1.0.163" serde_derive = "1.0.163" -shell-escape = "0.1.5" toml = "0.7.4" diff --git a/src/main.rs b/src/main.rs index 4e4079e..603cb2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -137,9 +137,15 @@ impl RustDoomLauncher { fn form_command_string(&self) -> String { match self.get_launcher_and_command(false) { Ok((launch, comms)) => { - //TODO - escape all the strings - let c = comms.join(" "); - format!("{} {}", launch, c) + let mut command_string = String::new(); + // Feels like a bit of a hack, but it works I think + command_string.push_str(&Cow::from(launch).to_string()); + for c in comms { + command_string.push_str(" \'"); + command_string.push_str(c); + command_string.push('\'') + } + command_string } Err(MyErrors::NoLauncher) => "Error: No launcher".to_string(), Err(MyErrors::NoIwad) => "Error: No IWAD".to_string(), @@ -364,7 +370,9 @@ impl eframe::App for RustDoomLauncher { ui.horizontal(|ui| { let mut text = self.form_command_string(); let window_size = frame.info().window_info.size; - ui.add(egui::TextEdit::multiline(&mut text).desired_width(window_size[0] * 0.9)); + ui.add( + egui::TextEdit::multiline(&mut text).desired_width(window_size[0] * 0.9), + ); }); } });