Can bash show a function's definition?

前端 未结 4 2051
野的像风
野的像风 2020-12-22 15:21

Is there a way to view a bash function\'s definition in bash?

For example, say I defined the function foobar

function foobar {
    echo          


        
4条回答
  •  感动是毒
    2020-12-22 15:39

    set | sed -n '/^foobar ()/,/^}/p'
    

    This basically prints the lines from your set command starting with the function name foobar () and ending with }

提交回复
热议问题