mal*_*lat 5 powershell chocolatey appveyor
我试图从choco installAppVeyor中的命令中删除一些冗长.这是我一直在尝试(如这里建议):
if (Test-Path "C:/ProgramData/chocolatey/bin/swig.exe") {
echo "using swig from cache"
} else {
choco install swig > NUL
}
Run Code Online (Sandbox Code Playgroud)
然而它失败了:
Redirection to 'NUL' failed: FileStream will not open Win32 devices such as
disk partitions and tape drives. Avoid use of "\\.\" in the path.
At line:4 char:5
+ choco install swig > NUL
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : RedirectionFailed
Command executed with exception: Redirection to 'NUL' failed: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.
Run Code Online (Sandbox Code Playgroud)
所以我的问题是有一种方法可以抑制choco installAppVeyor上PowerShell中命令的冗长程度吗?
nul是批处理语法.在PowerShell中,您可以使用$null,正如Mathias R. Jessen在他的评论中指出的那样:
choco install swig > $null
Run Code Online (Sandbox Code Playgroud)
其他选项是管道进入Out-Nullcmdlet,在变量中收集输出,或将其转换为void:
choco install swig | Out-Null
$dummy = choco install swig
[void](choco install swig)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1845 次 |
| 最近记录: |