@@ -83,16 +83,18 @@ void givenSimilarEnvVariableNames_whenResolveEnv_Vars_thenPartialMatchDoesNotOcc
8383 @ ParameterizedTest
8484 @ CsvSource ({
8585 // Env var not present, fallback used
86- "'${USERNAME:guest}', 'guest'" ,
87- "'Welcome ${USERNAME:anonymous}', 'Welcome anonymous'" ,
86+ "'${USERNAME:-guest}', 'guest'" ,
87+ "'${USERNAME:=guest}', 'guest'" ,
88+ "'Welcome ${USERNAME:-anonymous}', 'Welcome anonymous'" ,
8889 // Env var present, fallback ignored
89- "'${USER:guest}', 'John'" ,
90- "'Path: ${PATH:/default}', 'Path: /usr/bin'" ,
90+ "'${USER:-guest}', 'John'" ,
91+ "'${USER:=guest}', 'John'" ,
92+ "'Path: ${PATH:-/default}', 'Path: /usr/bin'" ,
9193 // Empty default
92- "'Empty fallback: ${MISSING:}', 'Empty fallback: '" ,
94+ "'Empty fallback: ${MISSING:- }', 'Empty fallback: '" ,
9395 // Mixed present and fallback
94- "'User=${USER}, ID=${ID:0000}', 'User=John, ID=0000'" ,
95- "'${MISSING1:default1} and ${MISSING2:default2}', 'default1 and default2'"
96+ "'User=${USER}, ID=${ID:- 0000}', 'User=John, ID=0000'" ,
97+ "'${MISSING1:- default1} and ${MISSING2:= default2}', 'default1 and default2'"
9698 })
9799 void givenDefaultEnvValues_whenResolve_thenFallbackOrUseEnvValue (
98100 String command , String expected ) {
@@ -108,9 +110,10 @@ void givenDefaultEnvValues_whenResolve_thenFallbackOrUseEnvValue(
108110 @ ParameterizedTest
109111 @ ValueSource (
110112 strings = {
113+ "${TOKEN:default}" , // Single colon no longer supported
111114 "${MISSING}" , // Still fails because no default
112115 "Hi ${MISSING}!" , // Same
113- "${A:} ${B}" // A has empty default, B is missing
116+ "${A:- } ${B}" // A has empty default, B is missing
114117 })
115118 void givenMissingEnvWithoutDefault_whenResolve_thenThrowException (String command ) {
116119 Map <String , String > envVariables = Map .of ("A" , "something" );
@@ -122,9 +125,11 @@ void givenMissingEnvWithoutDefault_whenResolve_thenThrowException(String command
122125
123126 @ ParameterizedTest
124127 @ CsvSource ({
125- "'${TOKEN:abc:def}', 'abc:def'" , // Semicolon inside fallback value
126- "'${TOKEN:abc:def:ghi}', 'abc:def:ghi'" , // colon is only split on first occurrence
127- "'${TOKEN:}', ''" // colon at the end
128+ "'${TOKEN:-abc:def}', 'abc:def'" , // Bash-style with colon in fallback
129+ "'${TOKEN:=abc:def}', 'abc:def'" , // Bash-style with colon in fallback
130+ "'${TOKEN:-abc:def:ghi}', 'abc:def:ghi'" , // Bash-style
131+ "'${TOKEN:-}', ''" , // Bash-style colon-dash at the end
132+ "'${TOKEN:=}', ''" // Bash-style colon-equals at the end
128133 })
129134 void givenFallbackWithColons_whenResolve_thenParseCorrectly (String command , String expected ) {
130135 Map <String , String > envVariables = Map .of (); // No TOKEN set
0 commit comments