-
由 Jared Parsons 提交于
Powershell has two methods of detecting error that have very different semantics: - $?: bool which represents status of last powershell operation - $lastexitcode: integer holding exit value of last windows command When Powershell directly executes a windows command these two variables are roughly interchangable. For example: ``` cmd > & msbuild BadProj > "$?:$lastexitcode" false:1 ``` When Powershell indirectly executes a windows command, say through Invoke-Expression, then the important differences show up. The $? variable will represent Invoke-Expression while $lastexitcode will represent the windows command. ``` cmd > Invoke-Expression "& msbuild BadProj" > "$?:$lastexitcode" true:1 ``` Updated the error checking around Exec to guard against this potentiall difference.
d9e5cf10