#Bash, 94 86 bytes (saved 8 bytes thanks to Digital Trauma)
p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2
Test (on Linux):
echo 'p=equal;q=than;(($1>$2))&&p=greater&&[ ]||(($1<$2))&&p=less||q=to;echo $1 is $p $q $2' > cmp.sh
chmod +x cmp.sh
./cmp.sh 10 12
10 is less than 12
The use of [ ]
after p=greater
is to prevent ||
operator from being evaluated before =
in the expression ...&&p=greater||(($1<$2))...
(the operator precedence!).
The alternative would be using brackets around (($1>$2))&&p=greater
and (($1<$2))&&p=less
, but brackets make inner scope for variables, so p
would be left unaltered.