LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-14-2009, 10:15 PM   #1
Alex_Dc
Member
 
Registered: Oct 2009
Posts: 104

Rep: Reputation: 22
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)?
 
Old 10-14-2009, 10:17 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
sure its not a mistake? i dont see any reason for it to be there
 
Old 10-14-2009, 11:07 PM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
'.' 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.
 
Old 10-14-2009, 11:25 PM   #4
Alex_Dc
Member
 
Registered: Oct 2009
Posts: 104

Original Poster
Rep: Reputation: 22
Eureka!

OK, I get the general idea. Now I just have to read the man for source and learn what sub-shells are. That's easy enough though, I can take it from here. Thank you!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: Problem writing simple LISP-function! raskol Programming 3 03-28-2008 07:20 PM
Slow file writing with 'fwrite' function in C-code... scho Programming 5 08-07-2006 01:42 AM
the meaning of no www (a question) salparadise General 8 08-25-2004 03:28 PM
writing a script to perform a function on each users mail folder jhill Linux - Newbie 2 08-24-2004 08:18 AM
Question: meaning of Hz in the Linux Kernel Arc4ne Linux - General 8 08-15-2004 11:12 PM


All times are GMT -5. The time now is 08:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration