@@ -88,7 +88,14 @@ EQUALS : '=' { if (!afterHealthcheck) atLineStart = false; };
8888// Flag with optional value: --name or --name=value
8989// Captures the entire flag as a single token, stopping at whitespace
9090// This avoids the greedy flagValue+ parsing issue while keeping shell commands working
91- FLAG : ' --' [a-zA-Z ] [a-zA-Z0 -9_-]* (' =' ~[ \t\r\n]+)? { if (!afterHealthcheck) atLineStart = false ; } ;
91+ // Flag values can contain quoted strings (which may include spaces)
92+ FLAG : ' --' [a-zA-Z ] [a-zA-Z0 -9_-]* (' =' FLAG_VALUE_PART +)? { if (!afterHealthcheck) atLineStart = false ; } ;
93+ fragment FLAG_VALUE_PART
94+ : ' "' ( ' \\ ' ~[\r\n] | ~[" \\\r\n ] )* '" ' // Double-quoted string (with escapes)
95+ | ' \' ' ~[' \r\n ]* ' \' ' // Single-quoted string (literal)
96+ | ~[ \t\r\n" '\\ ] // Unquoted character
97+ | '\\ ' ~[\r\n ] // Escaped character
98+ ;
9299
93100// Standalone -- (double dash without flag name) - used in shell commands
94101DASH_DASH : '--' { if (!afterHealthcheck) atLineStart = false; };
@@ -134,6 +141,10 @@ fragment COMMAND_SUBST_INNER : COMMAND_SUBST | ~[()];
134141// Content cannot span newlines (backtick command substitution doesn't support that)
135142BACKTICK_SUBST : ' `' ~[ \t\r\n`] ~[`\r\n]* ' `' { atLineStart = false ; } ;
136143
144+ // Lone dollar sign that doesn't match ENV_VAR, SPECIAL_VAR, or COMMAND_SUBST
145+ // This handles cases like $'hello' (bash ANSI-C quoting) where $ precedes a quote
146+ DOLLAR : ' $' { atLineStart = false ; } ;
147+
137148// Unquoted text (arguments, file paths, etc.)
138149// This should be after more specific tokens
139150// Note: comma is NOT excluded here - it's only special in JSON arrays
0 commit comments