fix: powershell escape backticks (#2044)

* fix: powershell escape backticks

* fix: less boilerplate
This commit is contained in:
HugoCasa
2023-08-13 01:04:45 +02:00
committed by GitHub
parent c2281ef5da
commit cddef1a50a
+4 -1
View File
@@ -1672,7 +1672,10 @@ async fn handle_powershell_job(
.collect::<Vec<(String, String)>>();
let pwsh_args = args_owned.iter().map(|(n, v)| format!("--{n} {v}")).join(" ");
let content = content.replace('$', r"\$"); // escape powershell variables
let content = content
.replace('$', r"\$") // escape powershell variables
.replace("`", r"\`"); // escape powershell backticks
write_file(job_dir, "main.sh", &format!("set -e\ncat > script.ps1 << EOF\n{content}\nEOF\npwsh -File script.ps1 {pwsh_args}\necho \"\"\nsleep 0.02")).await?;
let token = client.get_token().await;
let mut reserved_variables = get_reserved_variables(job, &token, db).await?;