diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 30b86844619..5309bc09cea 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1561,7 +1561,7 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd, (*cmdList)->command)) { /* Swap between if and else processing */ - processThese = !processThese; + processThese = !executecmds; /* Process the ELSE part */ if (processThese) { diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 16fdd436b8c..5351e9c1abe 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -667,7 +667,45 @@ if /c==/c ( ) else ( echo parameter detection seems to be broken ) - +SET elseIF=0 +if 1 == 1 ( + SET /a elseIF=%elseIF%+1 +) else if 1 == 1 ( + SET /a elseIF=%elseIF%+2 +) else ( + SET /a elseIF=%elseIF%+2 +) +if %elseIF% == 1 ( + echo else if seems to work +) else ( + echo else if seems to be broken +) +SET elseIF=0 +if 1 == 2 ( + SET /a elseIF=%elseIF%+2 +) else if 1 == 1 ( + SET /a elseIF=%elseIF%+1 +) else ( + SET /a elseIF=%elseIF%+2 +) +if %elseIF% == 1 ( + echo else if seems to work +) else ( + echo else if seems to be broken +) +SET elseIF=0 +if 1 == 2 ( + SET /a elseIF=%elseIF%+2 +) else if 1 == 2 ( + SET /a elseIF=%elseIF%+2 +) else ( + SET /a elseIF=%elseIF%+1 +) +if %elseIF% == 1 ( + echo else if seems to work +) else ( + echo else if seems to be broken +) echo --- case sensitivity with and without /i option if bar==BAR echo if does not default to case sensitivity if not bar==BAR echo if seems to default to case sensitivity diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 828a6517254..4dddc71cc86 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -438,6 +438,9 @@ Passed: file size check on subdir\a.a [8]@or_broken@Skipping file size check on if seems to work else seems to work if seems not to detect /c as parameter +else if seems to work +else if seems to work +else if seems to work --- case sensitivity with and without /i option if seems to default to case sensitivity if /i seems to work