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

[[ -x =command ]]

as i understand the documentation, this should either return 0 or !0 depending on whether a command "foo" can be found in the path:
	[[ -x =foo ]]

but if =foo can't be found, it craps out.

i've got this in my ~/.zshrc:
	[[ -x =most ]] && export PAGER=most

and i would expect that if "most" isn't in my path, nothing would happen (nothing, in this case, meaning the PAGER variable remains unset)... instead what actually happens that processing of ~/.zshrc dies with an error. not good!

a) should that work the way i'm doing it?
b) if not, what's the correct way to test if a command exists in the PATH?

as documented in zshmisc....

    -x file
true if file exists and is executable by current process. If file exists and is a directory, then the current process has permission to search in the directory.


Normal shell expansion is performed on the file, string and pattern arguments...


 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808

	"If Jesus Christ were to come today, people would not
	 even crucify him. They would ask him to dinner, and
	 hear what he had to say, and make fun of it."
		-- Thomas Carlyle

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