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

Re: A short form for if-then-else



On Thursday 15 of October 2009 20:36:50 Anonymous bin ich wrote:
> 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
> 

if which mailx > /dev/null; then ...

Attachment: signature.asc
Description: This is a digitally signed message part.



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