Fix some pipe and revirt one erly change as harumt sugest. and add alot
errorlevel most command handle the errorlevel right but it is alot work
todo
Modified: trunk/reactos/subsys/system/cmd/alias.c
Modified: trunk/reactos/subsys/system/cmd/attrib.c
Modified: trunk/reactos/subsys/system/cmd/cmd.c
Modified: trunk/reactos/subsys/system/cmd/copy.c
Modified: trunk/reactos/subsys/system/cmd/error.c
_____
Modified: trunk/reactos/subsys/system/cmd/alias.c
--- trunk/reactos/subsys/system/cmd/alias.c 2005-07-19 22:48:35 UTC
(rev 16651)
+++ trunk/reactos/subsys/system/cmd/alias.c 2005-07-19 23:25:50 UTC
(rev 16652)
@@ -113,7 +113,7 @@
{
s = (LPTSTR)malloc ((_tcslen (subst) +
1)*sizeof(TCHAR));
if (!s)
- {
+ {
error_out_of_memory ();
return;
}
@@ -312,6 +312,8 @@
return 0;
}
+ nErrorLevel = 0;
+
if (param[0] == _T('\0'))
{
PrintAlias ();
_____
Modified: trunk/reactos/subsys/system/cmd/attrib.c
--- trunk/reactos/subsys/system/cmd/attrib.c 2005-07-19 22:48:35 UTC
(rev 16651)
+++ trunk/reactos/subsys/system/cmd/attrib.c 2005-07-19 23:25:50 UTC
(rev 16652)
@@ -135,6 +135,7 @@
if (hFind == INVALID_HANDLE_VALUE)
{
ErrorMessage (GetLastError (), pszFile);
+ nErrorLevel = 1;
return;
}
@@ -164,6 +165,7 @@
if (hFind == INVALID_HANDLE_VALUE)
{
ErrorMessage (GetLastError (), pszFile);
+ nErrorLevel = 1;
return;
}
@@ -209,6 +211,8 @@
return 0;
}
+ nErrorLevel = 0;
+
/* build parameter array */
arg = split (param, &argc, FALSE);
_____
Modified: trunk/reactos/subsys/system/cmd/cmd.c
--- trunk/reactos/subsys/system/cmd/cmd.c 2005-07-19 22:48:35 UTC
(rev 16651)
+++ trunk/reactos/subsys/system/cmd/cmd.c 2005-07-19 23:25:50 UTC
(rev 16652)
@@ -1555,7 +1555,7 @@
OPEN_EXISTING, 0, NULL);
if (GetConsoleScreenBufferInfo(hConsole, &Info) == FALSE)
{
- ConOutFormatMessage(GetLastError());
+ ConErrFormatMessage(GetLastError());
return(1);
}
wColor = Info.wAttributes;
_____
Modified: trunk/reactos/subsys/system/cmd/copy.c
--- trunk/reactos/subsys/system/cmd/copy.c 2005-07-19 22:48:35 UTC
(rev 16651)
+++ trunk/reactos/subsys/system/cmd/copy.c 2005-07-19 23:25:50 UTC
(rev 16652)
@@ -185,7 +185,7 @@
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 @@
{
CloseHandle (hFileDest);
CloseHandle (hFileSrc);
- error_out_of_memory ();
+ ConOutResPuts(STRING_ERROR_OUT_OF_MEMORY);
nErrorLevel = 1;
return 0;
}
@@ -466,7 +466,9 @@
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 @@
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;
}
_____
Modified: trunk/reactos/subsys/system/cmd/error.c
--- trunk/reactos/subsys/system/cmd/error.c 2005-07-19 22:48:35 UTC
(rev 16651)
+++ trunk/reactos/subsys/system/cmd/error.c 2005-07-19 23:25:50 UTC
(rev 16652)
@@ -36,6 +36,8 @@
if (dwErrorCode == ERROR_SUCCESS)
return;
+ nErrorLevel = 1;
+
if (szFormat)
{
va_start (arg_ptr, szFormat);
@@ -49,14 +51,14 @@
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 @@
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 @@
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 @@
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 @@
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_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 @@
ConErrPrintf(_T("%s - %s\n"), szMsg, s);
else
ConErrPrintf(_T("%s.\n"), szMsg);
+
+ nErrorLevel = 1;
}