How to assign result of boolean expression?

Hello

I would to write the test on one line like :

declare -i x=0 y=0 

........
some code assign value 0 or 1 to x and y
........

# if either x or y or both is set to 1, then do something
if  [ $x -gt 0 ] -o [ $y -gt 0 ] ; then
   do_something
fi

Any help is welcome

-o is OR within [ ] (and in test arguments)
|| is OR in the shell
So it is either

if  [ $x -gt 0 -o $y -gt 0 ] ; then

or

if  [ $x -gt 0 ] || [ $y -gt 0 ] ; then
2 Likes

Thank you