Bug 15571

Summary: hush will bypass commands after the first one in elif
Product: Busybox Reporter: SimonQian <vsfos>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:
Attachments: patch to fix the bug, but need more test

Description SimonQian 2023-05-19 09:12:37 UTC
Created attachment 9591 [details]
patch to fix the bug, but need more test

Busybox is at the top of the git repo.

Tested on WSL ubuntu and orangepi linux by running the test script with command line: busybox hush test

the test script:
#!/bin/sh
if false; then
	: nothing
elif echo 'test-1'; echo 'test-2' ; echo 'test-3'; then
	echo "abcdefg-1"
fi
echo again
if echo 'test-1'; echo 'test-2' ; echo 'test-3'; then
	echo "abcdefg-1"
fi

Output of the test script on hush:
# ./busybox hush test
test-1
again
test-1
test-2
test-3
abcdefg-1

Output of the test script on bash:
#bash test
test-1
test-2
test-3
abcdefg-1
again
test-1
test-2
test-3
abcdefg-1
Comment 1 SimonQian 2023-05-19 20:56:09 UTC
The attached patch is wrong.
Comment 2 Denys Vlasenko 2023-05-25 12:31:12 UTC
Fixed in git, thank you.

commit 6824298ab4d3da40763af4d2d466a72745b8b593
Date:   Thu May 25 14:22:10 2023 +0200

    hush: fix ELIF cmd1;cmd2 THEN ... not executing cmd2, closes 15571