重定向到 'NUL' 失败:FileStream 不会打开 Win32 设备
Redirection to 'NUL' failed: FileStream will not open Win32 devices
我正在尝试从 AppVeyor 中的 choco install
命令中删除一些冗长的内容。这是我一直在尝试的(按照建议 here):
if (Test-Path "C:/ProgramData/chocolatey/bin/swig.exe") {
echo "using swig from cache"
} else {
choco install swig > NUL
}
但是它失败了:
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.
所以我的问题是有没有办法在 AppVeyor 上的 PowerShell 中抑制 choco install
命令的冗长?
nul
是批处理语法。在 PowerShell 中,您可以改用 $null
,正如 Mathias R. Jessen 在他的评论中指出的那样:
choco install swig > $null
其他选项通过管道传输到 Out-Null
cmdlet,将输出收集到变量中,或将其转换为 void
:
choco install swig | Out-Null
$dummy = choco install swig
[void](choco install swig)
我正在尝试从 AppVeyor 中的 choco install
命令中删除一些冗长的内容。这是我一直在尝试的(按照建议 here):
if (Test-Path "C:/ProgramData/chocolatey/bin/swig.exe") {
echo "using swig from cache"
} else {
choco install swig > NUL
}
但是它失败了:
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.
所以我的问题是有没有办法在 AppVeyor 上的 PowerShell 中抑制 choco install
命令的冗长?
nul
是批处理语法。在 PowerShell 中,您可以改用 $null
,正如 Mathias R. Jessen 在他的评论中指出的那样:
choco install swig > $null
其他选项通过管道传输到 Out-Null
cmdlet,将输出收集到变量中,或将其转换为 void
:
choco install swig | Out-Null
$dummy = choco install swig
[void](choco install swig)