3
我不明白为什么我看到这种行为在PowerShell中:PowerShell的陷阱未触发一贯
PS C:\> trap { "Got it!" } 1/0
Attempted to divide by zero.
At line:1 char:22
+ trap { "Got it!" } 1/0 <<<<
PS C:\> trap { "Got it!" } 1/$null
Got it!
Attempted to divide by zero.
At line:1 char:22
+ trap { "Got it!" } 1/$ <<<< null
为什么一个表达触发陷阱和其他不?
有道理。为了进一步支持你,这个: trap {“Got it!” } invoke-expression“1/0” 给出了预期的行为。 – zdan 2009-09-04 17:54:07