upvote
Afaik it's habit to give system paths precedence so a malicious script can't shadow e.g. sudo and steal your password, escalating a local file write into root
reply
Otoh, if you don't put your local path first, you can't override system binaries that you want to override.

Also, if something can write into your path, it can probably write to your shell config and/or the environment variables.

reply
deleted
reply
Why would you want to override system binaries
reply
Often, system binaries are ancient
reply
Are you a MacOS user by any chance?
reply
All sorts of utilities push themselves to the front of path: uv, mise, asdf, python virtual environments, nix shell, etc.

It is a theoretically nice ideal that fails immediately when you want project specific overrides.

reply
That’s not true with mise. You can add something to the front of PATH in front of mise bins and mise will respect that.
reply
AFAIK it's habit to allow your scripts to override system ones, so you can customize behavior.

I've always seen home dir, homebrew, etc prepending to PATH.

reply
That's important only for the people that add relative names (like '.') to their path.

Most people know better.

reply
by that time it's too late and should have been prevented appearing on the host much earlier
reply