Return error codes correctly, fixes 1109. Patch by Hartmut Birr.

svn path=/trunk/; revision=20204
This commit is contained in:
Andrew Munger 2005-12-16 03:00:02 +00:00
parent 4ce3d5c9e8
commit 8b5d19e781

View file

@ -353,6 +353,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
if (first == NULL) if (first == NULL)
{ {
error_out_of_memory(); error_out_of_memory();
nErrorLevel = 1;
return ; return ;
} }
@ -361,6 +362,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
{ {
free (first); free (first);
error_out_of_memory(); error_out_of_memory();
nErrorLevel = 1;
return ; return ;
} }
@ -370,6 +372,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
free (first); free (first);
free (rest); free (rest);
error_out_of_memory(); error_out_of_memory();
nErrorLevel = 1;
return ; return ;
} }
@ -380,6 +383,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
free (rest); free (rest);
free (full); free (full);
error_out_of_memory(); error_out_of_memory();
nErrorLevel = 1;
return ; return ;
} }
@ -450,7 +454,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
free (rest); free (rest);
free (full); free (full);
free (szFullName); free (szFullName);
nErrorLevel = 1;
return; return;
} }
@ -463,6 +467,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
free (rest); free (rest);
free (full); free (full);
free (szFullName); free (szFullName);
nErrorLevel = 1;
return; return;
} }
@ -525,6 +530,10 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
GetExitCodeProcess (prci.hProcess, &dwExitCode); GetExitCodeProcess (prci.hProcess, &dwExitCode);
nErrorLevel = (INT)dwExitCode; nErrorLevel = (INT)dwExitCode;
} }
else
{
nErrorLevel = 0;
}
CloseHandle (prci.hThread); CloseHandle (prci.hThread);
CloseHandle (prci.hProcess); CloseHandle (prci.hProcess);
} }
@ -540,7 +549,12 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
DebugPrintf (_T("[ShellExecute failed!: %s]\n"), full); DebugPrintf (_T("[ShellExecute failed!: %s]\n"), full);
#endif #endif
error_bad_command (); error_bad_command ();
nErrorLevel = 1;
} }
else
{
nErrorLevel = 0;
}
} }
// restore console mode // restore console mode
SetConsoleMode ( SetConsoleMode (
@ -1331,7 +1345,7 @@ ProcessInput (BOOL bFlag)
if (!(ip = ReadBatchLine (&bEchoThisLine))) if (!(ip = ReadBatchLine (&bEchoThisLine)))
{ {
if (bFlag) if (bFlag)
return 0; return nErrorLevel;
ReadCommand (readline, CMDLINE_LENGTH); ReadCommand (readline, CMDLINE_LENGTH);
ip = readline; ip = readline;
@ -1457,7 +1471,7 @@ ProcessInput (BOOL bFlag)
} }
while (!bCanExit || !bExit); while (!bCanExit || !bExit);
return 0; return nErrorLevel;
} }