如何编写将所有参数转发给委托命令的包装器 powershell 命令?

2024-03-23

wrapper应该只是打电话delegate,转发传递给包装器的参数。

Given

.\wrapper.ps1 1 2

Whendelegate.ps1 内容:

param($one, $two)
write-host "one=$one and two=$two"

Then期望输出为:

one=1 and two=2

包装器.ps1 内容:

.\delegate # How do I forward all args passed to this wrapper script to the delegate script?

如果我尝试以下wrapper.ps1的实现:

.\delegate $args

输出不正确:

one=1 2 and two=

您正在寻找的是泼溅 https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-6

使用@符号

.\delegate @args
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何编写将所有参数转发给委托命令的包装器 powershell 命令? 的相关文章

随机推荐