I've always been hesitant to include any user-defined directory in my
PATH environment variable or put custom scripts in an already included directory.
The reason for this is that I don't know how to avoid an (admittedly) unlikely edge case, i.e. a binary calling an external program which happens to have the same name as one of my custom scripts without the wanted binary existing on the machine and therefore the program actually calling my custom script instead which can only lead to trouble.
This is somewhat similar to shadowing a binary with a custom script of the same name like it's usually done with wrapper scripts. In this case, however, the program in question doesn't exist on the machine (only a custom script with the same name) and thus the position of the custom script location in the
PATH variable doesn't matter at all either.
Is there any way to avoid such a situation other than simply not storing custom scripts in directories used in the
PATH variable? The only possibility that comes to my mind is always using absolute paths to call custom scripts instead.