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

A short form for if-then-else



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?

-- 
Regards,



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