From 0f7ed8798be7ef33f91fd5c4cd751beec28601a1 Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Wed, 19 Jul 2023 15:26:21 +0200 Subject: [PATCH] fix: parse bash args with same-line comments (#1907) --- backend/parsers/windmill-parser-bash/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/parsers/windmill-parser-bash/src/lib.rs b/backend/parsers/windmill-parser-bash/src/lib.rs index 6e9b5a4eed..23e4c0ef24 100644 --- a/backend/parsers/windmill-parser-bash/src/lib.rs +++ b/backend/parsers/windmill-parser-bash/src/lib.rs @@ -18,7 +18,7 @@ pub fn parse_bash_sig(code: &str) -> anyhow::Result { } lazy_static::lazy_static! { - static ref RE: Regex = Regex::new(r#"(?m)^(\w+)="\$(?:(\d+)|\{(\d+):-(.*)\})"$"#).unwrap(); + static ref RE: Regex = Regex::new(r#"(?m)^(\w+)="\$(?:(\d+)|\{(\d+):-(.*)\})"(?:([\t ]*#.*)?)$"#).unwrap(); } fn parse_file(code: &str) -> anyhow::Result>> { @@ -66,6 +66,7 @@ mod tests { token="$1" image="$2" digest="${3:-latest with spaces}" +text="$4" # with comment "#; //println!("{}", serde_json::to_string()?); @@ -95,6 +96,13 @@ digest="${3:-latest with spaces}" typ: Typ::Str(None), default: Some(json!("latest with spaces")), has_default: false + }, + Arg { + otyp: None, + name: "text".to_string(), + typ: Typ::Str(None), + default: None, + has_default: false } ] }