Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Incorporating (( $+commands[foo] )) into a larger "if" statement
On Aug 5, 6:00pm, TJ Luoma wrote:
}
} if (( $+commands[foo] ))
$+commands[foo] is either 1 (commands[foo] is set) or 0 (not set).
The (( )) are a math context evaluation, so (( 1 )) is true. This
whole expression is a single shell command, so it can be used in any
position that an ordinary shell command can be used.
Thus to use this with other tests, you can either:
- Combine the test forms with && or || like:
if (( $+commands[growlnotify] )) && [ "`pgrep -x Growl`" != "" ]
- Test for 1 or 0 within the ordinary test such as:
if [ $+commands[growlnotify] = 1 -a "`pgrep -x Growl`" != "" ]
Messages sorted by:
Reverse Date,
Date,
Thread,
Author