Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A short form for if-then-else
- X-seq: zsh-users 14498
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: ZSH User List <zsh-users@xxxxxxxxxx>
- Subject: Re: A short form for if-then-else
- Date: Thu, 15 Oct 2009 18:56:34 +0200
- In-reply-to: <82839db60910150936o1d75fd27u80bd3aa41143f1c@xxxxxxxxxxxxxx>
- Mail-followup-to: ZSH User List <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <82839db60910150936o1d75fd27u80bd3aa41143f1c@xxxxxxxxxxxxxx>
Anonymous bin ich <ichbinanon@xxxxxxxxx>:
> 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?
Yeah, that question had an in-depth thread last time it came up. So,
you may be interested in this:
<http://www.zsh.org/mla/users/2007/msg00918.html>
Answers discuss various possible solutions, as well as their up- and
downsides.
Regards, Frank
Messages sorted by:
Reverse Date,
Date,
Thread,
Author