【发布时间】:2022-08-13 21:37:20
【问题描述】:
如此处所见https://superuser.com/questions/414036/get-definition-of-function-and-echo-the-code 这将获得测试功能的主体
${function:test-function}
但不是带有参数的测试函数的标题
-
你能举个例子说明你在追求什么吗?
标签: powershell
如此处所见https://superuser.com/questions/414036/get-definition-of-function-and-echo-the-code 这将获得测试功能的主体
${function:test-function}
但不是带有参数的测试函数的标题
标签: powershell
您必须自己添加缺少的部分才能形成完整的函数定义:
$funcDef = "function test-function { ${function:test-function} }"
如果您在变量中给出了函数名称,或者您希望避免重复函数名称:
$funcName = 'test-function'
$funcDef = "function $funcName {{ {0} }}" -f (Get-Item function:$funcName).Definition
【讨论】: