PowerShell ISE throws an error on git checkout -
in powershell, git checkout
runs without error message. in ise, while git checkout
stills works, ise gives error message.
> git checkout master branch ahead of 'origin/master' 3 commits. (use "git push" publish local commits) git : switched branch 'master' @ line:1 char:1 + git checkout master + ~~~~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (switched branch 'master':string) [], remoteexception + fullyqualifiederrorid : nativecommanderror
this isn't major problem, because git checkout
still works. it's annoying, though, i'd know why ise complains when standard powershell doesn't, , importantly, how can prevent annoyance.
i have looked @ why powershell ise showing errors powershell console not show?, explains ise displaying normal shell experiencing. reply not explain how quiet downwards annoying behavior.
there few ways can avoid these errors, none of them looks or feels 'natural'. first 1 uses error stream redirection , logic around errors:
$out = git ? 2>&1 if ($?) { $out } else { $out.exception }
second depends on erroraction, available powershell constructs, need build 1 first:
& { [cmdletbinding()] param() git ? } -erroraction silentlycontinue -errorvariable fail if ($fail) { $fail.exception }
in isegit module utilize latter avoid error records 'leaking' end user in uncontrolled manner.
finally can 'fix it' (well, sort off...) making sure can string in end:
"$(git ? 2>&1 )"
or vote against leave unaware of actual errors, setting global $erroractionpreference
silentlycontinue
- though not different redirecting error stream $null
.
git powershell powershell-v3.0 powershell-ise
No comments:
Post a Comment