Reputation: 281
The problem I am experience involves multiple IF statements. For some reason the script is validating against the code below even with the settings as follows:
SSLSite is Defined as N
SSLOnly is Undefined
Subdomain is Defined as N
if ([[ $SSLSite == y* || $SSLSite == Y* ]] && [[ $SSLOnly == n* || $SSLOnly == N* ]] && [[ $Subdomain == n* ]] || [[ $Subdomain == N* ]])
Any ideas?
Thanks.
Upvotes: 0
Views: 77
Reputation: 123640
To directly answer your question, the problem is your last condition: [[ $Subdomain == n* ]] || [[ $Subdomain == N* ]]
.
The ||
here is not grouped inside the [[ .. ]]
like in the other clauses. This gives you
(A || B) && (C || D) && (E) || (F)
where you wanted
(A || B) && (C || D) && (E || F)
The former expression is true if F
alone is true, which is why it's validating when Subdomain=N
You can solve it by making the last clause [[ $Subdomain == n* || $Subdomain == N* ]]
instead, but clearly anubhava's syntax is better.
Upvotes: 2
Reputation: 785866
Your long if condition can be shortened to:
[[ "$SSLSite" == [yY]* && "$SSLOnly" == [nN]* && "$Subdomain" == [nN]* ]]
Upvotes: 3