On Wed Nov 22 03:01:09 2023 +0000, eric pouech wrote:
it looks a bit strange that expand_envvar needs to behave differently if inside CMD_IF or not If I read your sample test correctly, the issue in Wine stems from 'if !WINE_FOO!==' being expanded and then parsed again in the if-command leading to a syntax error because of the space introduced in WINE_FOO expansion it rather looks like the delayed expansion is wrong as the !WINE_FOO! should rather be expanded **after** parsing that's likely a way larger change
I think you may have misread the diff: The patch adds an exception for `WCMD_IF` to `WCMD_execute`, not `WCMD_expand_envvar`. `WCMD_expand_envvar` is exactly the same as before, minus the `static` keyword. The call to `WCMD_expand_envvar(p, '!')` is merely delayed until after the `IF` statement is parsed, exactly as you say it should be.
It doesn't surprise me that `IF` has to be treated differently when `WCMD_execute` calls `handleExpansion` because there are many places where `IF` and `FOR` are already special-cased. There's a good chance that we will eventually have to add `&& cmd_index != WCMD_FOR` to the same two lines too.