Returning a value to a calling script

Hi. I'm trying to call a script named checkForFile.sh from within my main script named master.sh. In checkForFile.sh I want to set a value to the variable fileExist, but then I want to reference the value in the master.sh script. Whenever I attempt this the echo statement is just blank.

#master.sh
./checkForFile.sh
echo $fileExist

#checkForFile.sh (called from within master.sh)
fileExist=1

Is there a good way to accomplish this? What I'm trying obviously isn't working. Any help would be greatly appreciated!

You can do something like:

#master.sh
fileExist=$(./checkForFile.sh)
echo $fileExist
#checkForFile.sh (called from within master.sh)
fileExist=1
echo $fileExist

Regards

Well, you can EXPORT data to go from parent to child, but this does not help you in going from child back to parent (process).
A couple of thougts:
(a) You could utilize the return code from the child process. Instead of simply using an "exit", you could use "exit 1" (or whatever) to pass something back to the parent. Caution should be used in this application since returning any value is normally significant to there being an error in the child process.
(b) Write a temporary file, perhaps even with information in it. The child can create a work file that the parent program will read for next steps.

Personally, I like the 2nd approach as it is cleaner. However, with careful consideration, the 1st approach might also work for you.

hmm...so there is no way to make the called script a sort of Function that will return a value I designate?

Another way, run the script in the current shell:

#master.sh
. ./checkForFile.sh
echo $fileExist
#checkForFile.sh (called from within master.sh)
fileExist=1
export $fileExist

Regards

This worked perfectly! I really appreciate the help.