lib/tst_test.sh: fix ROD_SILENT command return status check
PATCH 1/1 lib/tst_test.sh: fix ROD_SILENT command return status check
"local tst_out=$(some_command)" always returns status 0, i.e. not the return status of the command in the assignment, but the status for 'local' builtin command, which creates a new local variable inside the function.
As a result, the library calls and tests that invoke ROD_SILENT don't actually check the return status of commands passed to it.
The old API library function is also fixed.
--- testcases/lib/test.sh | 4 +++- testcases/lib/tst_test.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
testcases/lib/test.sh +3 -1
@@ -233,7 +233,9 @@ tst_timeout() ROD_SILENT() { - local tst_out="$($@ 2>&1)" + local tst_out + + tst_out="$($@ 2>&1)" if [ $? -ne 0 ]; then echo "$tst_out" tst_brkm TBROK "$@ failed"
testcases/lib/tst_test.sh +3 -1
@@ -126,7 +126,9 @@ tst_brk() ROD_SILENT() { - local tst_out="$(tst_rod $@ 2>&1)" + local tst_out + + tst_out="$(tst_rod $@ 2>&1)" if [ $? -ne 0 ]; then echo "$tst_out" tst_brk TBROK "$@ failed"
Signature · 1 line
2.25.1
PATCH 1/1 lib/tst_test.sh: fix ROD_SILENT command return status check
Hi Alexey,
Quoted 7 lines
"local tst_out=$(some_command)" always returns status 0, i.e. not the return status of the command in the assignment, but the status for 'local' builtin command, which creates a new local variable inside the function.
As a result, the library calls and tests that invoke
ROD_SILENTdon't actually check the return status of commands passed to it.
Very good catch, thanks!
Working the same in: bash, dash, busybox sh, mksh (android).
Quoted 1 line
The old API library function is also fixed.
+1
Kind regards,
Petr
Alexey Kodanev
AppliedPATCH 1/1 lib/tst_test.sh: fix ROD_SILENT command return status check
Quoted 10 lines · Petr Vorel
Hi Alexey,
Quoted 7 lines
"local tst_out=$(some_command)" always returns status 0, i.e. not the return status of the command in the assignment, but the status for 'local' builtin command, which creates a new local variable inside the function.
As a result, the library calls and tests that invoke
ROD_SILENTdon't actually check the return status of commands passed to it.
Quoted 9 lines
Reviewed-by Petr Vorel <[email protected]>Very good catch, thanks!
Tested-by Petr Vorel <[email protected]>Working the same in: bash, dash, busybox sh, mksh (android).
Quoted 1 line
The old API library function is also fixed.
+1
Applied. Thanks Petr!