On Wednesday 04 Aug 2010 16:03:25 Peng Yu wrote:
 
> I have the following script and output. The man page says "Return  a
> status  of  0 or 1 depending on the evaluation of the conditional
> expression expression." Therefore, I thought that the two printf
> statements should print 1 and 0 respectively. But both of them print
> 0. I'm wondering what [[ should return if it is not used with a if
> statement.
> 
> $ cat main.sh
> #!/usr/bin/env bash
> 
> printf '%d\n' `[[ 10 -gt 1 ]]`
> printf '%d\n' `[[ 1 -gt 10 ]]`
> if [[ 10 -gt 1 ]]
> then
>   echo xxx
> fi
> $ ./main.sh
> 0
> 0
> xxx

You're confusing "return value of the command" with "output of the command".

-- 
D.

Reply via email to