/* search the PATH environment variable for the binary */
if (!SearchForExecutable (first, szFullName))
{
- if (!SearchForExecutable (full, szFullName))
- {
error_bad_command ();
free (first);
free (rest);
free (full);
free (szFullName);
return;
- }
}
LPCTSTR tmp;
BOOL bEchoThisLine;
BOOL bModeSetA;
+ BOOL bIsBatch;
do
{
ReadCommand (readline, CMDLINE_LENGTH);
ip = readline;
bEchoThisLine = FALSE;
+ bIsBatch = FALSE;
}
+ else
+ {
+ bIsBatch = TRUE;
+ }
/* skip leading blanks */
while ( _istspace(*ip) )
if (*commandline)
{
ParseCommandLine (commandline);
- if (bEcho && !bIgnoreEcho)
+ if (bEcho && !bIgnoreEcho && (!bIsBatch || bEchoThisLine))
ConOutChar ('\n');
bIgnoreEcho = FALSE;
}
for you can change the EnvirommentVariable for prompt before cmd start
this patch are not 100% right, if it does not exists a PROMPT value cmd should use
$P$G as defualt not set EnvirommentVariable PROMPT to $P$G if it does not exists */
- if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, 2 * sizeof(TCHAR)) == 0)
+ if (GetEnvironmentVariable(_T("PROMPT"),lpBuffer, sizeof(lpBuffer) / sizeof(lpBuffer[0])) == 0)
SetEnvironmentVariable (_T("PROMPT"), _T("$P$G"));
++i;
if (i < argc)
{
- _tcscpy (commandline, argv[i]);
+ _tcscpy (commandline, _T("\""));
+ _tcscat (commandline, argv[i]);
+ _tcscat (commandline, _T("\""));
while (++i < argc)
{
_tcscat (commandline, _T(" "));
_tcscat (commandline, argv[i]);
}
-
ParseCommandLine(commandline);
}
}
{
ParseCommandLine (_T("\\cmdstart.bat"));
}
-#ifndef __REACTOS__
- else
- {
- /* try to run cmdstart.bat from install dir */
- LPTSTR p;
-
- _tcscpy (commandline, argv[0]);
- p = _tcsrchr (commandline, _T('\\')) + 1;
- _tcscpy (p, _T("cmdstart.bat"));
-
- if (IsExistingFile (_T("commandline")))
- {
- LoadString(CMD_ModuleHandle, STRING_CMD_ERROR4, szMsg, RC_STRING_MAX_SIZE);
- ConErrPrintf(szMsg, commandline);
- ParseCommandLine (commandline);
- }
- }
-#endif
#ifdef FEATURE_DIR_STACK
/* initialize directory stack */
static VOID Cleanup (int argc, TCHAR *argv[])
{
-#ifndef __REACTOS__
- TCHAR szMsg[RC_STRING_MAX_SIZE];
-#endif
-
/* run cmdexit.bat */
if (IsExistingFile (_T("cmdexit.bat")))
{
ConErrResPuts (STRING_CMD_ERROR5);
ParseCommandLine (_T("\\cmdexit.bat"));
}
-#ifndef __REACTOS__
- else
- {
- /* try to run cmdexit.bat from install dir */
- TCHAR commandline[CMDLINE_LENGTH];
- LPTSTR p;
-
- _tcscpy (commandline, argv[0]);
- p = _tcsrchr (commandline, _T('\\')) + 1;
- _tcscpy (p, _T("cmdexit.bat"));
-
- if (IsExistingFile (_T("commandline")))
- {
- LoadString(CMD_ModuleHandle, STRING_CMD_ERROR4, szMsg, RC_STRING_MAX_SIZE);
- ConErrPrintf(szMsg, commandline);
- ParseCommandLine (commandline);
- }
- }
-#endif
#ifdef FEATURE_ALIASES
DestroyAlias ();
}
}
-#ifdef __REACTOS__
-#ifdef _UNICODE
-PWCHAR * _CommandLineToArgvW(PWCHAR lpCmdLine, int *pNumArgs)
-{
- PWCHAR * argvw = NULL;
- PWCHAR ptr = lpCmdLine;
- PWCHAR str;
- int len;
- int NumArgs;
-
- NumArgs = 0;
-
- while(lpCmdLine && *lpCmdLine)
- {
- while (iswspace(*lpCmdLine)) lpCmdLine++;
- if (*lpCmdLine)
- {
- if ((NumArgs % 10)==0)
- {
- PWCHAR * old_argvw = argvw;
- argvw = malloc((NumArgs + 10) * sizeof(PWCHAR));
- memcpy(argvw, old_argvw, NumArgs * sizeof(PWCHAR));
- free(old_argvw);
- }
- ptr = wcschr(lpCmdLine, L' ');
- if (ptr)
- {
- len = ptr - lpCmdLine;
- }
- else
- {
- len = wcslen(lpCmdLine);
- }
- str = malloc((len + 1) * sizeof(WCHAR));
- memcpy(str, lpCmdLine, len * sizeof(WCHAR));
- str[len] = 0;
- argvw[NumArgs]=str;
- NumArgs++;
- lpCmdLine = ptr;
- }
- }
- *pNumArgs = NumArgs;
- return argvw;
-}
-#endif
-#endif
-
/*
* main function
*/
#ifdef _UNICODE
PWCHAR * argv;
int argc=0;
-#ifdef __REACTOS__
- argv = _CommandLineToArgvW(GetCommandLineW(), &argc);
-#else
argv = CommandLineToArgvW(GetCommandLineW(), &argc);
-#endif
#endif
GetCurrentDirectory(MAX_PATH,startPath);