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

Incorporating (( $+commands[foo] )) into a larger "if" statement



OK, so I am apparently mis-understanding something or I've forgotten
something about how this works.

Some time ago, someone from the list suggested that I could do this instead
of using `which`

if (( $+commands[foo] ))
then

echo yes

fi


that works fine. However, what I am trying to do now is check for other
things at the same time.

For example, if I want to check that the command `growlnotify` is found in
the $PATH and I want to check to see if `pgrep` finds 'Growl' is running.
In that instance I would use this to check `pgrep`:

if [ "`pgrep -x Growl`" != "" ]
then
echo Not Running
else
echo Is Running
fi

but I can't figure out how to put that together with

if (( $+commands[growlnotify] ))

OR, if I want to see if the command `bbedit` is found, and I want to check
that a variable $APP is equal to "bbedit". I would do the latter

if [ "$APP:l" == "bbedit" ]
then
echo yes
else
echo no
fi


Any help would be appreciated.

Thanks!

TjL


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