From: Julien Nicoulaud <julien.nicoulaud@gmail.com>
To: Anonymous bin Ich <ichbinanon@gmail.com>
Cc: zsh-users@zsh.org
Subject: Re: Check existence of a program
Date: Tue, 1 Feb 2011 20:01:40 +0100 [thread overview]
Message-ID: <AANLkTin=vdAq--1hudVrXQQJOqhgr6WvmTT_ccVM_cVP@mail.gmail.com> (raw)
In-Reply-To: <4D4850F7.6060205@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 998 bytes --]
if type exiftime &>/dev/null; then ...
2011/2/1 Anonymous bin Ich <ichbinanon@gmail.com>
> Hello!
>
> I am having trouble checking for existence of a program.
>
> This works:
>
> % cat working.zsh
> #!/bin/zsh
> set -x
> prog="identify"
> path=$(which ${prog})
> %
> % ./working.zsh
> +./working.zsh:3> prog=identify
> +./working.zsh:4> path=+./working.zsh:4> which identify
> +./working.zsh:4> path=/usr/bin/identify
> %
>
> But this doesn't:
>
> % cat notworking.zsh
> #!/bin/zsh
> set -x
> prog="exiftime"
> path=$(which ${prog})
> if [[ ${?} -ne 0 ]]; then
> prog="identify"
> path=$(which ${prog})
> fi
> %
> % ./notworking.zsh
> +./notworking.zsh:3> prog=exiftime
> +./notworking.zsh:4> path=+./notworking.zsh:4> which exiftime
> +./notworking.zsh:4> path='exiftime not found'
> +./notworking.zsh:5> [[ 1 -ne 0 ]]
> +./notworking.zsh:6> prog=identify
> +./notworking.zsh:7> path=+./notworking.zsh:7> which identify
> +./notworking.zsh:7> path='identify not found'
> %
>
> Any idea?
>
next prev parent reply other threads:[~2011-02-01 19:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-01 18:29 Anonymous bin Ich
2011-02-01 19:01 ` Julien Nicoulaud [this message]
2011-02-01 19:16 ` Benjamin R. Haskell
2011-02-01 19:16 ` Jérémie Roquet
2011-02-01 20:16 ` Bart Schaefer
2011-02-01 21:39 ` Atom Smasher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTin=vdAq--1hudVrXQQJOqhgr6WvmTT_ccVM_cVP@mail.gmail.com' \
--to=julien.nicoulaud@gmail.com \
--cc=ichbinanon@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).