【发布时间】:2020-03-01 08:40:43
【问题描述】:
我想扩展cd 的功能,但保留Set-Location 的所有现有参数。所以我创建了一个函数go,它做了一堆额外的事情,然后给它起了别名cd(我不得不使用-Option AllScope 来让它工作,有谁知道为什么我不能只是重新别名cd不用那个?)
Set-Alias cd go -Option AllScope
问题是我希望go 做某些事情,但也希望在调用标准Set-Location 开关时故障转移到Set-Location 功能:
Set-Location -LiteralPath <String> [-PassThru] [-UseTransaction] [<CommonParameters>]
Set-Location [[-Path] <String>] [-PassThru] [-UseTransaction] [<CommonParameters>]
Set-Location [-PassThru] [-StackName <String>] [-UseTransaction] [<CommonParameters>]
在通过创建辅助函数然后以这种方式重新使用内置别名来扩展内置 Cmdlet 的功能方面寻求建议?即,我希望 cd 继续执行所有 Set-Location 功能,除非将我想要的新开关应用于现在别名为的辅助功能?
【问题讨论】:
标签: powershell alias