Comment by function_seven

6 years ago

It’s to avoid collisions altogether, not to prioritize the custom commands over the standard ones.

For example, let’s say I have a script that improves upon the systemctl command, and I want to use it all the time and not type a bunch of characters to invoke it. I might call it “sc”, forgetting that I also use the spreadsheet calculator sometimes.

If I always prefix, then “,sc” is my shortcut, and “sc” is the spreadsheet calculator.

There isn't just the risk of a name clash between programs that you use. It's a hygiene problem: a clash that you don't know about, involving some program you don't use (or not directly).

The system programs can potentially rely on each other, invoking each other in a way that relies on PATH searching, and not set PATH to a sane value when they are invoked. Your utility can accidentally shadow something and break the program whicc relies on it.

In other words, setting PATH to point to ~/bin first breaks unhygienic programs which blindly inherit PATH --- which is pretty much all non-setuid programs in a Unix-like system!

Setting PATH to point to your ~/bin last, on the other and, potentially breaks your programs when they call each other (in a way that relies on path searching), and are shadowed by new system programs. A fix for that is to to put ~/bin last, and ensure that all your programs refer to each other in a way that doesn't rely on PATH. E.g. prog is invoked as $bob_utils/prog.

Got it thanks -- that's what I was calling "namespacing" then yeah.

Not a problem I've ever had, but I guess I like the solution if it's one you do often.

Thanks for confirming.