Skip to content

Commit 678e6c8

Browse files
tnevrlkalcarva
authored andcommitted
Handle empty severe_violations variable
The `severe_violations` variable is being created by jq which counts critical and high severity violations in a json file generated in previous step. If the json file is empty, the `severe_violations` variable is also empty. Checking an empty variable with `[` and the `-eq` operator leads to a `integer expression expected` error in Bash (but not in Z shell) resulting to a failure in logic and the Task unexpectedly passing. However, using `[[` works as expected and considers an empty string and 0 to be equal. ``` bash-5.2$ [ "" -eq 0 ] && echo equal || echo not bash: [: : integer expression expected not bash-5.2$ [[ "" -eq 0 ]] && echo equal || echo not equal ``` Signed-off-by: Tomáš Nevrlka <tnevrlka@redhat.com>
1 parent 327f407 commit 678e6c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rhtap/acs-image-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function rox-image-check() {
6464
)
6565

6666
# If roxctl image check exited with non-zero code and it is not because of policy violations, report error
67-
if [ "$severe_violations" -eq 0 ]; then
67+
if [[ "$severe_violations" -eq 0 ]]; then
6868
exit "$ROXCTL_CHECK_STATUS"
6969
fi
7070
}

0 commit comments

Comments
 (0)