If we take a look at the following example:
# testing(){ echo hello;}
# testing
hello
# echo $(testing)
hello
# echo testing >script
# ./script
./script: line 1: testing: command not found
# source ./script
hello
# export -f testing
# ./script
hello
It tus out that a bash function needs to be exported only if you want to use it in a non-sourced script. I tried several levels of subshells, the behavior is the same. Can someone confirm this, because I find it contradictory with the claim that local variables do not exist in subshells.
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 171
تاريخ: سه
شنبه
21 ارديبهشت
1395 ساعت: 7:06