Merge pull request #689 from PowerShell/throw-error-code
Fix powershell -c 'throw error'
This commit is contained in:
commit
d7a2ba713e
1 changed files with 7 additions and 1 deletions
|
@ -233,7 +233,7 @@ OPTIONS
|
||||||
// run the initial script
|
// run the initial script
|
||||||
if (initialScript != null)
|
if (initialScript != null)
|
||||||
{
|
{
|
||||||
ExecuteHelper(initialScript, null);
|
Execute(initialScript);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,6 +432,9 @@ OPTIONS
|
||||||
{
|
{
|
||||||
if (e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
|
// Return non-zero exit code if an exception is thrown
|
||||||
|
this.ExitCode = 1;
|
||||||
|
|
||||||
object error;
|
object error;
|
||||||
IContainsErrorRecord icer = e as IContainsErrorRecord;
|
IContainsErrorRecord icer = e as IContainsErrorRecord;
|
||||||
if (icer != null)
|
if (icer != null)
|
||||||
|
@ -547,6 +550,9 @@ OPTIONS
|
||||||
// the user calling "exit".
|
// the user calling "exit".
|
||||||
while (!this.ShouldExit && this.myHost.Runspace != null)
|
while (!this.ShouldExit && this.myHost.Runspace != null)
|
||||||
{
|
{
|
||||||
|
// Reset exit code for each command
|
||||||
|
this.ExitCode = 0;
|
||||||
|
|
||||||
// If the prompt function failed for any reason, use a sane default
|
// If the prompt function failed for any reason, use a sane default
|
||||||
string prompt;
|
string prompt;
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in a new issue