Quote:
Originally Posted by igadoter
Hi, I today tested some simple scripts and noticed something I don't understand. Say
works fine in $HOME directory. I mean if script is called in $HOME as working directory. However I have to put prefix
to make script works outside $HOME. If I don't do that I get error 'file not found'. That's a mess.
|
Then
${HOME} is in your
PATH. Wherever you're trying to source it where you've found that a "
./" prefix makes it work is obviously
not in your
PATH.
One workaround is to add "
:." to the end of your
PATH variable (and re-exporting it). That way, every directory on the system is potentially a location of executable and sourceable files when you're
in the directory. However this is typically frowned upon for security reasons. (I'm not certain that those reasons makes much sense any more, though.) Finally, as was pointed out in by another responder, using full path names in program names and files in scripts is best. The time spent typing them in is far shorter than the time it takes debugging "file not found" messages.
Style note: when sourcing files in a script, it's often preferable to use "
source" instead of "
.". It's easy to miss a single "
." in a script.
Good luck...