Executing this command my end up with 'null':
oauth_token=$(curl -kls \
--header "Authorization: Bearer $TFE_TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request GET $HOST/api/v2/organizations/$ORGANIZATION/oauth-clients | jq -r ".data[] | select(.attributes.name == \"$1\") | .relationships.\"oauth-tokens\".data[0].id")
info "oauth token is: $oauth_token"
if [[ -z $oauth_token ]]; then
warn "Connection to VSC was not successful as oauth_token is null."
exit 0
fi
The log output is like this:
[INFO] Showing oauth token of myuser...
[INFO] oauth token is: null
null
null
[INFO] Setting oauth token as env variable)
Why does the 'if' clause in that case not work?
Why does the 'if' clause in that case not work?Becausenull null nullis not an empty string.