Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: trying directories in path one by one
- X-seq: zsh-workers 55243
- From: Mandar Mitra <mandar.mitra@xxxxxxxxx>
- To: "Mark J. Reed" <markjreed@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: trying directories in path one by one
- Date: Wed, 4 Nov 2026 20:15:36 +0530
- Archived-at: <https://zsh.org/workers/55243>
- In-reply-to: <CAA=-s3wxTn9GRw0ad_YvXNqz25OfVwyDwdZyNQVPR+zEZ=64qg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <austIm10YPnn-uOx@gmail.com> <CAA=-s3wxTn9GRw0ad_YvXNqz25OfVwyDwdZyNQVPR+zEZ=64qg@mail.gmail.com>
Mark J. Reed wrote (Wed, Nov 04, 2026 at 08:54:59AM -0500):
> 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?
Sorry, my bad. What I'm seeing is that if execve (?) fails on the virtualenv pip with a bad interpreter error, then /bin/pip runs. With 2>&1, I see
zsh: ..../junk/bin/pip: bad interpreter: .... /junk/bin/python: no such file or directory
followed by the output from (I'm guessing) /bin/pip.
I'd like things to stop at the bad interpreter error, so that I don't miss it amidst all the other output.
Is this configurable?
Thanks,
Mandar.
> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author