Skip to content

Commit

Permalink
Fix broken conditional in gpg.sh
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
grdryn committed Jun 27, 2019
1 parent 2c57c93 commit e64c6ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion image/tools/lib/encryption/gpg.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e64c6ba

Please sign in to comment.