From e64c6bad30b051673dc624ef694181061e477637 Mon Sep 17 00:00:00 2001 From: Gerard Ryan Date: Thu, 27 Jun 2019 09:39:29 +0000 Subject: [PATCH] Fix broken conditional in gpg.sh Using `if [` works differently than `if [[` (the former single square bracket is a file, the double one is a builtin function (I think)). When using `if [` with `-eq`, it expects numbers, but `==` can deal with strings, which is what we want here. Some examples: ```bash $ if [ hello -eq hello ]; then echo yes; fi bash: [: hello: integer expression expected $ if [ hello == hello ]; then echo yes; fi yes $ if [ 1 -eq 1 ]; then echo yes; fi yes $ if [[ hello -eq hello ]]; then echo yes; fi yes $ if [[ 1 -eq 1 ]]; then echo yes; fi yes ``` --- image/tools/lib/encryption/gpg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image/tools/lib/encryption/gpg.sh b/image/tools/lib/encryption/gpg.sh index c196d49..ced7ed6 100644 --- a/image/tools/lib/encryption/gpg.sh +++ b/image/tools/lib/encryption/gpg.sh @@ -1,6 +1,6 @@ function check_encryption_enabled { local result=$(oc get secret -n ${ENCRYPTION_SECRET_NAMESPACE} ${ENCRYPTION_SECRET_NAME} -o template --template='{{.metadata.name}}') - if [ "$result" -eq "${ENCRYPTION_SECRET_NAME}" ]; then + if [ "$result" == "${ENCRYPTION_SECRET_NAME}" ]; then return 0 else return 1