[SOLVED] Bash some questions please
by iammike2 from LinuxQuestions.org on (#4S2T4)
Guys,
sorry to bother you again. I have a couple of Bash questions
Suppose I have 2 scripts like this
script1
Code:#!/bin/bash
echo "In script 1"
source script2.sh
echo "back in script 1"
exit 0
script2
Code:#!/bin/bash
echo "in script 2"
exit 0Question 1:
Is using "source" the best way to call another script or ???
I would prefer to have the scripts in the same Dir as the "Main" script, but if that is not a good idea, please let me know
Question 2:
Must I use exit 0 (or any other errorlevel) or use return to leave SCRIPT2 or is that not necessary ?
Question 3:
And must I use exit "number" at the end of the main script or is that also not necessary (not doing anything with the output (yet ;) )
Thx again guys, really appreciated.


sorry to bother you again. I have a couple of Bash questions
Suppose I have 2 scripts like this
script1
Code:#!/bin/bash
echo "In script 1"
source script2.sh
echo "back in script 1"
exit 0
script2
Code:#!/bin/bash
echo "in script 2"
exit 0Question 1:
Is using "source" the best way to call another script or ???
I would prefer to have the scripts in the same Dir as the "Main" script, but if that is not a good idea, please let me know
Question 2:
Must I use exit 0 (or any other errorlevel) or use return to leave SCRIPT2 or is that not necessary ?
Question 3:
And must I use exit "number" at the end of the main script or is that also not necessary (not doing anything with the output (yet ;) )
Thx again guys, really appreciated.