shell在执行的时候是顺序执行的,也不存在什么多线程什么的。

一下是实现种类:

1、全局

g_result=""  
  
function testFunc()  
{  
    g_result='local value'  
}  
  
testFunc  
echo $g_result  

2、局部

function testFunc()  
{  
    local_result='local value'  
    echo $local_result  
}  
  
result=$(testFunc)  
echo $result  

3、return返回特殊用法

function test() {
  return 1
}

echo $?

可以看出$?是用来接收的

 

 

参考:

https://www.linuxjournal.com/content/return-values-bash-functions

http://www.blogjava.net/xzclog/archive/2015/09/21/427407.html

https://blog.csdn.net/mdx20072419/article/details/9381339

相关文章:

  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2023-03-19
  • 2021-11-29
  • 2022-01-25
  • 2022-12-23
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-02-22
相关资源
相似解决方案