Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: twisted braces

On Jul 24,  7:46am, zzapper wrote:
} I got into a twist recently with conditional braces ie if (( [[ and [

(( ... )) is not for conditional expressions, it's for arithmetic.  It
happens that the results of arithmetic can be tested with "if" et al.,
but that's not its primary purpose.

} My problems were solved by using the single [.

That probably means you needed filename generation or another operation
that occurs for ordinary commands.

} I read in the doc that (( was no longer recommended?

Where?  Quote, please.  If true, that should be repaired.

} From my Bash days I seem to think [[ was required for substring matching?

[[ ... ]] is a true syntactic construct whereas [ ... ] is merely a
command (a synonym for "test ...").  Therefore the shell applies very
different rules inside [[ ... ]], one of which is that comparisons
use pattern matching and another of which is that filename generation
is not performed (so that glob patterns can be used for comparisons).

} Comments?


In particular, the sections "Shell Grammar" and "Conditional Expressions".

Messages sorted by: Reverse Date, Date, Thread, Author