For some reason (?), often when I write scripts nowadays they do not work, or work only in part, and then I try with .
or source
and they work perfectly. I'm unsure what is causing this as the scripts are different in a lot of ways, it's hard to isolate what must be sourced in order for the script as a whole to work. Also, I've noticed that this is almost always the case when I move things from .bashrc
aliases and functions into scripts.
But to my actual question, in the above situation, what is the optimal way to "swallow" the source dot, so you are still able to use the scripts as one-word commands, not having to hit the dot every time?
.
are NOT valid reasons to choose one over the other, and conflating the syntax will probably break many things. Once you understand the differences between functions, scripts, and sourced scripts, come back and describe what you are really trying to do. – jw013 Sep 10 '12 at 20:16.
is not that hard to type. Or, make a function:script () { . script; }
and use that instead. – jw013 Sep 10 '12 at 20:17