diff --git a/reactos/subsys/system/cmd/alias.c b/reactos/subsys/system/cmd/alias.c index e77df7e775e..2479083d982 100644 --- a/reactos/subsys/system/cmd/alias.c +++ b/reactos/subsys/system/cmd/alias.c @@ -113,7 +113,7 @@ AddAlias (LPTSTR name, LPTSTR subst) { s = (LPTSTR)malloc ((_tcslen (subst) + 1)*sizeof(TCHAR)); if (!s) - { + { error_out_of_memory (); return; } @@ -312,6 +312,8 @@ INT CommandAlias (LPTSTR cmd, LPTSTR param) return 0; } + nErrorLevel = 0; + if (param[0] == _T('\0')) { PrintAlias (); diff --git a/reactos/subsys/system/cmd/attrib.c b/reactos/subsys/system/cmd/attrib.c index 0e7a5d657bd..d5deefee8c8 100644 --- a/reactos/subsys/system/cmd/attrib.c +++ b/reactos/subsys/system/cmd/attrib.c @@ -135,6 +135,7 @@ ChangeAttribute (LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask, if (hFind == INVALID_HANDLE_VALUE) { ErrorMessage (GetLastError (), pszFile); + nErrorLevel = 1; return; } @@ -164,6 +165,7 @@ ChangeAttribute (LPTSTR pszPath, LPTSTR pszFile, DWORD dwMask, if (hFind == INVALID_HANDLE_VALUE) { ErrorMessage (GetLastError (), pszFile); + nErrorLevel = 1; return; } @@ -209,6 +211,8 @@ INT CommandAttrib (LPTSTR cmd, LPTSTR param) return 0; } + nErrorLevel = 0; + /* build parameter array */ arg = split (param, &argc, FALSE); diff --git a/reactos/subsys/system/cmd/cmd.c b/reactos/subsys/system/cmd/cmd.c index b75579f98b6..c735114a49b 100644 --- a/reactos/subsys/system/cmd/cmd.c +++ b/reactos/subsys/system/cmd/cmd.c @@ -1555,7 +1555,7 @@ int _main (int argc, char *argv[]) OPEN_EXISTING, 0, NULL); if (GetConsoleScreenBufferInfo(hConsole, &Info) == FALSE) { - ConOutFormatMessage(GetLastError()); + ConErrFormatMessage(GetLastError()); return(1); } wColor = Info.wAttributes; diff --git a/reactos/subsys/system/cmd/copy.c b/reactos/subsys/system/cmd/copy.c index 6aa771e3722..70fd4fd319d 100644 --- a/reactos/subsys/system/cmd/copy.c +++ b/reactos/subsys/system/cmd/copy.c @@ -185,7 +185,7 @@ int copy (TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], int append, DWORD lpdwFl if (hFileDest == INVALID_HANDLE_VALUE) { CloseHandle (hFileSrc); - error_path_not_found (); + ConOutResPuts(STRING_ERROR_PATH_NOT_FOUND); nErrorLevel = 1; return 0; } @@ -194,7 +194,7 @@ int copy (TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], int append, DWORD lpdwFl { CloseHandle (hFileDest); CloseHandle (hFileSrc); - error_out_of_memory (); + ConOutResPuts(STRING_ERROR_OUT_OF_MEMORY); nErrorLevel = 1; return 0; } @@ -466,7 +466,9 @@ INT cmd_copy (LPTSTR cmd, LPTSTR param) default: /* invaild switch */ - error_invalid_switch(_totupper(arg[i][1])); + LoadString(CMD_ModuleHandle, STRING_ERROR_INVALID_SWITCH, szMsg, RC_STRING_MAX_SIZE); + ConOutPrintf(szMsg, _totupper(arg[i][1])); + return 1; break; } @@ -488,14 +490,15 @@ INT cmd_copy (LPTSTR cmd, LPTSTR param) if(nFiles < 1) { /* There is not enough files, there has to be at least 1 */ - error_req_param_missing(); + ConOutResPuts(STRING_ERROR_REQ_PARAM_MISSING); return 1; } if(nFiles > 2) { /* there is too many file names in command */ - error_too_many_parameters(""); + LoadString(CMD_ModuleHandle, STRING_ERROR_TOO_MANY_PARAMETERS, szMsg, RC_STRING_MAX_SIZE); + ConErrPrintf(szMsg,_T("")); nErrorLevel = 1; return 1; } diff --git a/reactos/subsys/system/cmd/error.c b/reactos/subsys/system/cmd/error.c index 4db018df09a..3bd901d2c6e 100644 --- a/reactos/subsys/system/cmd/error.c +++ b/reactos/subsys/system/cmd/error.c @@ -36,6 +36,8 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...) if (dwErrorCode == ERROR_SUCCESS) return; + nErrorLevel = 1; + if (szFormat) { va_start (arg_ptr, szFormat); @@ -49,14 +51,14 @@ VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...) NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&szError, 0, NULL)) { - ConOutPrintf (_T("%s %s\n"), szError, szMessage); + ConErrPrintf (_T("%s %s\n"), szError, szMessage); LocalFree (szError); return; } else { LoadString(CMD_ModuleHandle, STRING_ERROR_ERROR1, szMsg, RC_STRING_MAX_SIZE); - ConOutPrintf(szMsg, dwErrorCode); + ConErrPrintf(szMsg, dwErrorCode); return; } @@ -94,7 +96,8 @@ VOID error_parameter_format(TCHAR ch) TCHAR szMsg[RC_STRING_MAX_SIZE]; LoadString(CMD_ModuleHandle, STRING_ERROR_PARAMETERF_ERROR, szMsg, RC_STRING_MAX_SIZE); - ConOutPrintf(szMsg, ch); + ConErrPrintf(szMsg, ch); + nErrorLevel = 1; } @@ -103,7 +106,8 @@ VOID error_invalid_switch (TCHAR ch) TCHAR szMsg[RC_STRING_MAX_SIZE]; LoadString(CMD_ModuleHandle, STRING_ERROR_INVALID_SWITCH, szMsg, RC_STRING_MAX_SIZE); - ConOutPrintf(szMsg, ch); + ConErrPrintf(szMsg, ch); + nErrorLevel = 1; } @@ -112,20 +116,21 @@ VOID error_too_many_parameters (LPTSTR s) TCHAR szMsg[RC_STRING_MAX_SIZE]; LoadString(CMD_ModuleHandle, STRING_ERROR_TOO_MANY_PARAMETERS, szMsg, RC_STRING_MAX_SIZE); - ConOutPrintf(szMsg, s); + ConErrPrintf(szMsg, s); + nErrorLevel = 1; } VOID error_path_not_found (VOID) { - ConOutResPuts(STRING_ERROR_PATH_NOT_FOUND); + ConErrResPuts(STRING_ERROR_PATH_NOT_FOUND); nErrorLevel = 1; } VOID error_file_not_found (VOID) { - ConOutResPuts(STRING_ERROR_FILE_NOT_FOUND); + ConErrResPuts(STRING_ERROR_FILE_NOT_FOUND); nErrorLevel = 1; } @@ -135,20 +140,22 @@ VOID error_sfile_not_found (LPTSTR f) TCHAR szMsg[RC_STRING_MAX_SIZE]; LoadString(CMD_ModuleHandle, STRING_ERROR_FILE_NOT_FOUND, szMsg, RC_STRING_MAX_SIZE); - ConOutPrintf(_T("%s - %s\n"), szMsg, f); + ConErrPrintf(_T("%s - %s\n"), szMsg, f); nErrorLevel = 1; } VOID error_req_param_missing (VOID) { - ConOutResPuts(STRING_ERROR_REQ_PARAM_MISSING); + ConErrResPuts(STRING_ERROR_REQ_PARAM_MISSING); + nErrorLevel = 1; } VOID error_invalid_drive (VOID) { - ConOutResPuts(STRING_ERROR_INVALID_DRIVE); + ConErrResPuts(STRING_ERROR_INVALID_DRIVE); + nErrorLevel = 1; } @@ -162,18 +169,21 @@ VOID error_bad_command (VOID) VOID error_no_pipe (VOID) { ConErrResPuts(STRING_ERROR_CANNOTPIPE); + nErrorLevel = 1; } VOID error_out_of_memory (VOID) { ConErrResPuts(STRING_ERROR_OUT_OF_MEMORY); + nErrorLevel = 1; } VOID error_invalid_parameter_format (LPTSTR s) { - ConOutResPuts(STRING_ERROR_INVALID_PARAM_FORMAT); + ConErrResPuts(STRING_ERROR_INVALID_PARAM_FORMAT); + nErrorLevel = 1; } @@ -187,6 +197,8 @@ VOID error_syntax (LPTSTR s) ConErrPrintf(_T("%s - %s\n"), szMsg, s); else ConErrPrintf(_T("%s.\n"), szMsg); + + nErrorLevel = 1; }