Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A short form for if-then-else
- X-seq: zsh-users 14495
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Anonymous bin ich <ichbinanon@xxxxxxxxx>
- Subject: Re: A short form for if-then-else
- Date: Thu, 15 Oct 2009 18:42:41 +0200
- Cc: ZSH User List <zsh-users@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=NGC3zEv/+sliUtihGV+Y9scB1KHognWJWNez4yR1ztw=; b=lzbvHJ15JT45vM2Uj824yf4Fyv0rLadmYavws25DYTBAbuqgFuPfXfO/548k5Poz0o D3H/yRuXccCSe29KGk1Ew0/Y8Ea1Onk778RU8fBqWOgQRh/LF4Qmix2QqzlxS0/BxJ/I J610D0Gk+O00LJzNazoa/PpB5//SEnS9EBIUE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=bvFPiVzyz17Au55yw2hQcYDcWH0zmJRH5OSxRyd/oRcnTEmdnNeysRHvN8pEc+67gI 6WfnxgHDaHx/J3cjS8zObsJ3I0k0u3Pdt9AkgyeuGCdMNCfyRU9PD8otmnAiX90uMkJM l1bcTKNnogvVTgEcpfWJk8WCm6tEzNQolyvYc=
- In-reply-to: <82839db60910150936o1d75fd27u80bd3aa41143f1c@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <82839db60910150936o1d75fd27u80bd3aa41143f1c@xxxxxxxxxxxxxx>
2009/10/15 Anonymous bin ich <ichbinanon@xxxxxxxxx>:
> Hi!
>
> I want to check if a program (mailx) is present or not. If present,
> the program will be run, if not, an error message should be printed.
> No other message should be printed.
>
> I have tried following ways:
>
> which mailx &>/dev/null && mailx || echo "not found"
>
> but when mailx exits with non 0 error code, "not found" is printed.
>
> I tried
>
> if [[ -x =mailx ]]; then mailx; else echo "not found"; fi
>
> but when mailx is not present, zsh prints an error which I cannot seem
> to redirect to /dev/null
>
> Any other way to do it without involving local variables or different
> external programs?
if which mailx &> /dev/null; then
foo
else
bar
fi
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author