Shell 如何更改函数中的字符串?

Shell 如何更改函数中的字符串?,shell,Shell,我正在写一个函数 func-def.sh: function func() { # assign _f_desc here .... } run-main.sh : function call_all_func() { source func-def.sh # when I call the function from here _f_desc= func _f_desc # here I must get the function d

我正在写一个函数

func-def.sh:

function func() {
    # assign _f_desc here ....
}


run-main.sh :


function call_all_func() {
    source func-def.sh
    # when I call the function from here
    _f_desc= 
    func _f_desc
    # here I must get the function description of the function
    # that was last executed ... 
}

简而言之,我想将_f_desc传递给func,并希望func填写一个描述其用法的短字符串。。例如_f_desc可能包含此函数乘以2个

,无需显式传递变量即可对其进行更改。请参见下面的脚本:

function call_all_func() {
   local _f_desc
   func
   echo "$_f_desc"
}

function func() {
   _f_desc="This function multiplies 2 nos"
}
现在请致电:

call_all_func
它将打印:

This function multiplies 2 nos