我只是不喜欢以下语法:
if (Test-Path $path) { ... }
Run Code Online (Sandbox Code Playgroud)
和
if (-not (Test-Path $path)) { ... }
if (!(Test-Path $path)) { ... }
Run Code Online (Sandbox Code Playgroud)
特别是在检查"不存在"这种常见用途时,括号太多且不易读.有什么更好的方法呢?
更新:我目前的解决方案是使用别名exist,并not-exist为解释在这里.
PowerShell存储库中的相关问题:https://github.com/PowerShell/PowerShell/issues/1970
powershell ×1