I am working on a script that goes:
#script_1.sh
function a() {
export var1='...some calculations on $@...';
}
function b() {
a "$@"
local loc_b=$var1
}
function c() {
a "$@"
local loc_c=$var1
}
#script_2.sh
source script_1.sh
b val1 &
c val2 &
b val2 &
function a has getopt command and parses parameters for b and c. This has been simplified to a great extent.
When I call function b, function c and function b again at the end as background processes, I worry that I might have a race condition on assigning the exported var1 variable to the local variable.
If I can guarantee that calls to
function borfunction cwill be as background processes, do I have to worry about the race condition here?If there is no race, can I get away by not declaring the local variables for each function?