Zsh Mailing List Archive
Messages sorted by:
Incorporating (( $+commands[foo] )) into a larger "if" statement
- X-seq: zsh-users 20384
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: Incorporating (( $+commands[foo] )) into a larger "if" statement
- Date: Wed, 5 Aug 2015 18:00:18 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=j4R/YU2cWRf34c8+rcm2B0FIWVUpm052gdTGyp4Wx5I=; b=zynU1sXcY7u1c0gk3UstGWhBzvFgm0VYnoaMPkQkaZF0fCouhd7Hib8ko6WtvpErQ7 J1Er4p2QDWXjp6Ktznu0fZIXjMzBXP7B9Y8JvM8YCwIu/E7ggdnnjCCYyQerUPgvQ8D4 QzYH2aOFpW/QyS2nvvdbQmsQTTRQClAP4Q/DVRoQKQ+mPwq+34ruGxaDaRCIepVoadJm XIZYJV/z5+/AqcCkYxjDAA2O8JTrh7DyNAW6CREJdB0/CSXwVkpiB89YB/cVOIot42rC mPqcdfUlfYE8PzB5jx+17Ln+Kr0Rl82h3QYN/KSpwjqNVoKbOFBfbLv4MLGV4yj5AY0a bNVA==
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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] ))
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`" != "" ]
echo Not Running
echo Is Running
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" ]
Any help would be appreciated.
Messages sorted by: