mardi 26 juin 2018

ksh if loop vs [[ ]] && { cmd1 ; } || { cmd2 ; }

I am working on a shell script and following syntax works fine:

if [[ 1 -eq 1 ]] ; then
   [[ 2 -eq 1 ]]
else
   echo hi
fi

Debug run : + [[ 1 -eq 1 ]] + [[ 2 -eq 1 ]]

If i shrink the statement it jumps to the else condition:

**[[ 1 -eq 1 ]] && { [[ 2 -eq 1 ]] ; } || echo hi**

Debug run:

+ [[ 1 -eq 1 ]]
+ [[ 2 -eq 1 ]]
+ echo hi
hi

any ideas what is missing?

Thanks much. Sam

Aucun commentaire:

Enregistrer un commentaire