Skip to content

Expand env vars in all arguments - #13034

Merged
Simn merged 2 commits into
developmentfrom
bring-back-env-arg-expansion
Sep 9, 2026
Merged

Expand env vars in all arguments#13034
Simn merged 2 commits into
developmentfrom
bring-back-env-arg-expansion

Conversation

@Simn

@Simn Simn commented Sep 8, 2026

Copy link
Copy Markdown
Member

Yuxiao found that we broke this in #12737. There used to be an extra loop that would expand_env all arguments, so I'm bringing that back for now.

This currently causes consistent failures in the sys tests, which suggests that some behavior changed somewhere after all.

because that's what we did before
@Simn

Simn commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

The old code I'm referring to is this:

			let rec loop acc args = match args with
				| "--display" :: arg :: args ->
					loop (arg :: "--display" :: acc) args
				| arg :: args ->
					loop (Helper.expand_env arg :: acc) args
				| [] ->
					List.rev acc
			in
			let args = loop [] args in
			Arg.parse_argv ~current (Array.of_list ("" :: args)) all_args_spec args_callback "";

If we ignore the --display stuff which is handled differently now, this should really be equivalent to let args = List.map Helper.expand_env args in, so it should be correct in this regard.

I'm trying to understand how this is even related to the failing sys tests which don't appear to be about the expansion of environment variables in arguments at all.

@tobil4sk

tobil4sk commented Sep 8, 2026

Copy link
Copy Markdown
Member

Those failing sys tests are complaining that %PATH% is being expanded when passed to native target programs. It seems somehow haxe is interferring with how those values are passed to the native programs.

Also, this behaviour should be windows only, the %VAR% syntax is windows cmd.exe specific.

@Simn

Simn commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Yes, for now I'd like to just bring back the old behavior and understand what actually changed because I'm worried that I'm overlooking something here.

@tobil4sk

tobil4sk commented Sep 8, 2026

Copy link
Copy Markdown
Member

It looks like each target test also runs the eval one for some reason (which is why every target is failing):

var exitCode = run("haxe", ["compile-each.hxml", "--run", "TestArguments"].concat(args));

It seems even the arguments passed after --run are expanded, which the test doesn't like. Perhaps the old code didn't do that?

@Simn

Simn commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Perhaps the old code didn't do that?

It seems that way, but I don't understand why because that loop thing I pasted should affect every argument...

@tobil4sk

tobil4sk commented Sep 8, 2026

Copy link
Copy Markdown
Member

Maybe the previous setup was already splitting out the haxe compiler args from the --run args before that point?

@Simn

Simn commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Ah, I think you're right, that was this whole sys_args business in process_params that happened at a higher level. Hmm, in that case I'll have to think about how to handle this in the new system. I guess for now I'll just turn it into a loop that stops on --run, although that's more of a hack than a proper implementation.

@Simn
Simn marked this pull request as ready for review September 9, 2026 06:12
@Simn
Simn merged commit 8549cea into development Sep 9, 2026
155 of 158 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants