Results 1 to 3 of 3

Thread: Simple bash scritpting question

  1. #1

    Simple bash scritpting question

    I've read a bash scripting tutorial and now I read various scripts and try to understand what they are doing.
    What I've seen many times and don't really know what it does is something like this:

    # Source function library.
    . /etc/rc.d/init.d/functions
    # Source networking configuration.
    . /etc/sysconfig/network
    Ok, "functions" and "network" are scripts that are executed here - but what is the ". " for? Why not just "/etc/rc.d/init.d/functions" instead of ". /etc/rc.d/init.d/functions"

  2. #2

    Re:Simple bash scritpting question

    "." = source command

    Pasted from 'man bash' (I think words "in the current shell environment" are the key here):

    . filename [arguments]
    source filename [arguments]
    Read and execute commands from filename in the cur-
    rent shell environment and return the exit status
    of the last command executed from filename. If
    filename does not contain a slash, file names in
    PATH are used to find the directory containing
    filename. The file searched for in PATH need not
    be executable. When bash is not in posix mode, the
    current directory is searched if no file is found
    in PATH. If the sourcepath option to the shopt
    builtin command is turned off, the PATH is not
    searched. If any arguments are supplied, they
    become the positional parameters when filename is
    executed. Otherwise the positional parameters are
    unchanged. The return status is the status of the
    last command exited within the script (0 if no com-
    mands are executed), and false if filename is not
    found or cannot be read.

  3. #3

    Re:Simple bash scritpting question

    If the script defines an alias, variable, or function (which is what they do, in this case), then those aliases, variables, and functions will be lost after the script exits if the '.' is not present. The '.' allows those aliases, variables, and functions to be inserted into the "current shell environment" for use by the script later on.

Similar Threads

  1. (Hopefully) Simple question regarding samba
    By elovkoff in forum Linux - Hardware, Networking & Security
    Replies: 9
    Last Post: 10-28-2002, 06:21 PM
  2. Simple Question
    By CP in forum General Chat
    Replies: 47
    Last Post: 09-16-2002, 10:09 PM
  3. Simple Question
    By Baldy in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 07-26-2002, 03:39 PM
  4. MOVED: Simple bash scritpting question
    By in forum Linux - General Topics
    Replies: 0
    Last Post: 06-30-2002, 08:40 PM
  5. simple WindowMaker question
    By in forum Linux - Software, Applications & Programming
    Replies: 25
    Last Post: 05-01-2002, 03:37 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts