LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Simple Question? The 'DOT' in a shell script test (https://www.linuxquestions.org/questions/linux-newbie-8/simple-question-the-dot-in-a-shell-script-test-790543/)

spampig 02-21-2010 07:59 AM

Simple Question? The 'DOT' in a shell script test
 
I was looking at this line in an init file:

Code:

test -f /etc/default/postfix && . /etc/default/postfix
Which I understand to mean test that files /etc/default/postfix AND etc/default/postfix exist. Two things crossed my mind.

First, There was no action associated with the line at all - so regardless of the result of the test, it appears to be superfluous - unless....

I noted the period/dot just after the && and I don't honestly know what it means in this context.

Google would be the first port of call, but searching for '.' is notorious. The best I could find was 'run in the same shell' but I can't make the connection in my brain of where this fits in to the context of the test.

Can anyone put me out of my misery?

macemoneta 02-21-2010 08:01 AM

The statement reads, if /etc/default/postfix exists, then source /etc/default/postfix.

The '.' means source the file. That is, make the contents of the file part of the current environment.

Usually the file will contain functions and/or variables that are set.

spampig 02-21-2010 08:45 AM

I never knew that! You've given me a much needed pointer to find out more. Really appreciate it - thanks for your time and response.


All times are GMT -5. The time now is 12:55 AM.