Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Powershell 7.2Write-Output ($false || $true)中将输出False. 为什么?
Write-Output ($false || $true)
False
因为它不是“逻辑或”,所以应该是-oror -bor。它正在执行“如果第一个命令失败,则运行第二个命令”。
-or
-bor
引用变量$false不会失败,因此$true不会执行引用变量。
$false
$true
为了比较,试试asdfg || $true,如果找不到命令,你会得到一个错误,然后$true。
asdfg || $true