check for = false explicitly instead of != true#485
check for = false explicitly instead of != true#485mwoolweaver wants to merge 2 commits intopi-hole:developmentfrom
= false explicitly instead of != true#485Conversation
Signed-off-by: Michael Woolweaver <michael@woolweaver.bid>
|
|
||
| # Try to login again until the session is valid | ||
| while [ "${validSession}" != true ] ; do | ||
| while [ "${validSession}" = false ] ; do |
There was a problem hiding this comment.
I'm not sure about this change. validSession is set by Authenticate() which get it from
If anything goes wrong, it might contain something unexpected or is empty. Therefore, I would keep this check as it was
There was a problem hiding this comment.
I agree.
If the curl command (in Authenticate() function) fails with an error message instead of a JSON payload, then jq will also fail.
In this case, validSession will be an empty string and the comparison will return different values.
export validSession=''
if [ "${validSession}" != true ]; then echo "try again"; else echo "stop the loop"; fi
This will print try again.
if [ "${validSession}" = false ]; then echo "try again"; else echo "stop the loop"; fi
This will print stop the loop.
Your command expects the same result in both cases, but we get the opposite when we have a string different than "true" or "false".
We are basically comparing strings here. We want to try again if validSession contains anything different than true, not only when validSession is exactly false.
|
Pinging @mwoolweaver |
1 similar comment
|
Pinging @mwoolweaver |
What does this PR aim to accomplish?:
check for
= falseexplicitly instead of!= true.By submitting this pull request, I confirm the following:
git rebase)