tags:

views:

31

answers:

1

How can I set my intial variables in a re-usable way? I tried to do this by invoking something like this in my child script:

 ./init.bash

And inside init.bash:

prod="false"

if [ "$prod" == "prod" ]
then
    RUN_DIR=/home/windsor/.scripts/websites
    JAVA_DIR=/home/windsor/prog/websitechecker
    OUT_DIR=/tmp/
    DB="prod"
else
    if [ ! -a /tmp/test ]
    then
        mkdir /tmp/test
    fi
    DB="mydb"
    OUT_DIR=/tmp/test/
    RUN_DIR=/home/windsor/workspaces/bash/websites
    JAVA_DIR=/home/windsor/workspaces/java/testrun
fi

cd $RUN_DIR
+3  A: 

Use the source command:

source ./init.bash

If you are typing it in on the command-line, you can use the shortcut:

. ./init.bash
Marcelo Cantos