<div dir="ltr"><div>I have to agree that that isn't the most efficient method for keeping</div><div>track of the "errorlevel_changed". I will be resubmitting the patch</div><div>with a better implementation, using the process stack as you</div><div>suggested.<br><br>However, I would like to say that it really wouldn't be possible to only</div><div>use the success/failure value from the functions that don't change the</div><div>"errorlevel". This is because there is a subtle difference that sadly</div><div>Windows thought was a great idea (I think it should work like you say).</div><div>Windows checks if the "errorlevel" has changed in <u>any</u> of the commands</div><div>inside of a call and if it has then it checks the errorlevel, if it hasn't</div><div>changed it assumes a success. This means that even if the last</div><div>command "succeeds" without changing the errorlevel it doesn't matter</div><div>(e.g. "echo test") if any of the previous commands inside of a call</div><div>updated the errorlevel. Working examples can be seen on line 291-312</div><div>of programs/cmd/tests/test-builtins.cmd or a small snippet of them</div><div>below:<br><br></div><div>-snip<br></div><div>> :cfail<br>> echo %1<br>> call :setError 1<br>> goto :eof<br></div>-snip-<br><div>> call :cfail c1||call :cfail c2</div><div>-snip-</div><div>> :setError<br>> exit /B %1</div><div>-snip-<br></div><div><br></div><div>The code above will return (and would do so even if one inserted</div><div>a "echo foobar" after the "call :setError 1"):</div><div>c1</div><div>c2<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 19, 2017 at 5:27 AM, Alexandre Julliard <span dir="ltr"><<a href="mailto:julliard@winehq.org" target="_blank">julliard@winehq.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Alexander Coffin <<a href="mailto:alexcoffin1999@gmail.com">alexcoffin1999@gmail.com</a>> writes:<br>
<br>
> @@ -1478,7 +1557,9 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,<br>
>      switch (i) {<br>
><br>
>        case WCMD_CALL:<br>
> +        push_errorlevel_changed();<br>
>          WCMD_call (p);<br>
> +        pop_errorlevel_changed();<br>
<br>
</span>This seems to be the only place that does this, so I don't see why you<br>
need to manage your own stack instead of saving/restoring things on the<br>
process stack.<br>
<br>
Also returning a success/failure value from the various functions that<br>
implement commands would probably be cleaner than adding a global<br>
'changed' flag.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Alexandre Julliard<br>
<a href="mailto:julliard@winehq.org">julliard@winehq.org</a><br>
</font></span></blockquote></div><br></div>