idioms for returning multiple values in shell scripting

后端 未结 10 941
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-29 20:56

Are there any idioms for returning multiple values from a bash function within a script?

http://tldp.org/LDP/abs/html/assortedtips.html describes how to echo multipl

10条回答
  •  渐次进展
    2020-12-29 21:52

    I am new to bash, But found this code helping.

    function return_multiple_values() {
            eval "$1='What is your name'"
            eval "$2='my name is: BASH'"
        }
        
        return_var=''
        res2=''
        return_multiple_values return_var res2
        echo $return_var
        echo $res2
    

提交回复
热议问题