From 6407d9ff5ce51e71ff8b8fc503d89a2bdc2e1761 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 15 Jul 2026 12:46:26 +0200 Subject: [PATCH] fix(bash): normalize CRLF line endings before running scripts (#10131) Co-authored-by: Claude Opus 4.8 (1M context) --- backend/windmill-worker/src/bash_executor.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/windmill-worker/src/bash_executor.rs b/backend/windmill-worker/src/bash_executor.rs index 3101541d36..2da8f8d73f 100644 --- a/backend/windmill-worker/src/bash_executor.rs +++ b/backend/windmill-worker/src/bash_executor.rs @@ -74,6 +74,18 @@ pub async fn handle_bash_job( occupancy_metrics: &mut OccupancyMetrics, _killpill_rx: &mut tokio::sync::broadcast::Receiver<()>, ) -> Result, Error> { + // Normalize carriage returns to LF: bash reads a trailing `\r` as part of the + // command and fails with `$'\r': command not found`. Content can arrive with + // CRLF (Windows editor, browser paste, git sync) or a bare CR, so strip every + // `\r` rather than trusting the source. Only allocate when one is present. + let content_owned; + let content = if content.contains('\r') { + content_owned = content.replace("\r\n", "\n").replace('\r', "\n"); + content_owned.as_str() + } else { + content + }; + let annotation = windmill_common::worker::BashAnnotations::parse(&content); // `# sandbox ` selects the daemonless, nsjail-sandboxed container runtime