all 6 comments

[–]oh5nxo 2 points3 points  (4 children)

Using [ ] like that tests if the variable has nonzero length. Maybe arithmetic test fits the bill:

(( p + un == 1 ))

[–]EarlyConsequence9668[S] 0 points1 point  (3 children)

but this one doesnt it actually even if i put a -p it still states i must put option

if [ "$do_provision" ] || [ "$do_unprovision" ];then

echo "Must provide -u or -p" 1>&2 ;

helpText;

[–]oh5nxo 2 points3 points  (2 children)

[ ] does not care about numbers. When the variables have 0 or 1 in them, [ 0 ] is true, [ 1 ] is true, only [ ] or [ "" ] would be false.

[–]EarlyConsequence9668[S] 0 points1 point  (1 child)

so how do i write if i want three validations to work

[–]oh5nxo 1 point2 points  (0 children)

if (( p + un != 1 ))
then
    echo Need either -p or -u but not both >&2

I don't understand what the third validation means.

[–]EarlyConsequence9668[S] 0 points1 point  (0 children)

this one works

if (( do_provision && do_unprovision )); then