Re: bash does not jump where it is supposed to jump

2008-01-19 Thread Jan Schampera
William Tambe wrote:

> The code below should only print end

> [ "test" = "test" ] && {
> # after the false command bash should jump directly to echo end
> # but instead run echo echo "test != test"
> false
> } || {
> echo "test != test"
> }
> 
> echo end

It's okay like that, it's like lists (&&, || chained commands) should
work. If it's not safe for you, just use an ''if'':


snipsnap
if [ "test" = "test" ]; then
  false
else
  echo "test != test"
fi

echo end
snipsnap

J.




Re: bash does not jump where it is supposed to jump

2008-01-19 Thread Andreas Schwab
William Tambe <[EMAIL PROTECTED]> writes:

> [ "test" = "test" ] && {
>   # after the false command bash should jump directly to echo end
>   # but instead run echo echo "test != test"
>   false
> } || {
>   echo "test != test"
> }

true && false is false, thus the echo is executed.

Andreas.

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Re: Comparison failure

2008-01-19 Thread Jan Schampera
Chet Ramey wrote:
> Dave Rutherford wrote:
> 
>> Now, "[[" isn't very well documented, so I tend not to use it,
> 
> I'm always interested in suggestions for improving the bash documentation.
> Can you tell me what's unclear about the existing description of
> `[['?
> 
> Chet
> 

The documentation is complete. What some people always seem to forget
is, that it's a reference, not a tutorial. You can't start to learn from
the documentation.

IMHO the job of the Bash documentation is to tell that "[[ ]]" exists,
its working prionciple, and its differences to "[". But its job is not
to tell *why* it exists.

So, if the Bash documentation (mainly talking about the manpage here) is
intended to be used as a reference, then it's definitely complete. When
you know what you're searching for, you find it within a minute in 95%
of the cases.

J.