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

Re: trying directories in path one by one



What do you mean by "fails"? Zsh will execute the first one that is, well, executable. It doesn't run it and then check the exit code and keep looking through the PATH for another one to try. Perhaps you could be very specific about exactly what you are seeing?

On Wed, Nov 4, 2026 at 8:34 AM Mandar Mitra <mandar.mitra@xxxxxxxxx> wrote:
Hello,

If I have a command that is available in multiple directories in PATH, zsh's behaviour suggests that it tries them in turn until one succeeds. Is there an option / environment variable / similar that I can use to turn this off?

For example, pip could be available from both a virtualenv and the system location (/bin). If the virtualenv pip fails, I'd like to know right away, without the stderr messages getting lost in the voluminous output from /bin/pip.

I looked in the FAQ and man zshoptions, and didn't find a direct answer to this question (HASH_CMDS seemed tangentally related, though). I also asked Claude, which pointed me to Src/exec.c in the zsh source, but said it didn't know of a zsh option that disables the fallthrough.

Many thanks for any pointers, suggestions, etc.
Mandar.



--
Mark J. Reed <markjreed@xxxxxxxxx>


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