Writing a function, question about a symbol's meaning
Generally I prefer to avoid asking simple questions, but I can't seem to get any information on this one. If I were to write this function, for example:
if [ -f ~/.bashrc ]; then . ~/.bashrc fi what does the '.' in the second line indicate ('.' ~/.bashrc)? |
sure its not a mistake? i dont see any reason for it to be there
|
'.' is equivalent to 'source'. Both are bash builtins, so, check the bash man page to see what 'source' does.
The basic purpose of 'source' is to dump the contents of a shell script on the current shell, instead of spawning a new sub-shell. This is done this way because in bashrc you usually set a number of variables, and setting them into a subshell really makes no sense, since they will go away when the script exits. So, if you want a shell to run on the current shell you 'source' it instead of running it the traditional way. |
Eureka!
OK, I get the general idea. Now I just have to read the man for source and learn what sub-shells are. :D That's easy enough though, I can take it from here. Thank you! |
All times are GMT -5. The time now is 04:29 PM. |