| Summary: | Wrong exit code in xargs | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Masar <masar> |
| Component: | Standard Compliance | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | 1.28.x | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
|
Description
Masar
2018-10-05 12:38:58 UTC
Here is a sample command that shows the problem:
echo "1 2 3" | busybox xargs -n 1 -I '{}' sh -c "exit 255" ; echo $?
This command shoud print '124' as exit code, but in newer versions it returns '0'
I tested on varioius linux systems and with docker:
1.29: ERROR
1.28: ERROR
1.27: OK
1.26: OK
DOCKER: latest
docker run -ti --rm busybox:latest
/ # echo 1 2 3 | /bin/busybox xargs -n 1 -I '{}' sh -c 'exit 255' ; echo $?
xargs: sh: exited with status 255; aborting
0
DOCKER: 1.29
docker run -ti --rm busybox:1.29
/ # echo 1 2 3 | /bin/busybox xargs -n 1 -I '{}' sh -c 'exit 255' ; echo $?
xargs: sh: exited with status 255; aborting
0
DOCKER: 1.28
docker run -ti --rm busybox:1.28
/ # echo 1 2 3 | /bin/busybox xargs -n 1 -I '{}' sh -c 'exit 255' ; echo $?
xargs: sh: exited with status 255; aborting
0
DOCKER: 1.27
docker run -ti --rm busybox:1.27
/ # echo 1 2 3 | /bin/busybox xargs -n 1 -I '{}' sh -c 'exit 255' ; echo $?
xargs: sh: exited with status 255; aborting
124
DOCKER: 1.26
docker run -ti --rm busybox:1.26
/ # echo 1 2 3 | /bin/busybox xargs -n 1 -I '{}' sh -c 'exit 255' ; echo $?
xargs: sh: exited with status 255; aborting
124
Fixed in git:
commit f3e2838fc4e6bd0713d7ee5a17e752a19870a0f8
Date: Tue Oct 30 14:40:17 2018 +0100
xargs: fix exit code if command exits nonzero, closes 11381
|