Implement escape char in console. "^" cmd.c - when the env isnt found, dont zero out the params redir.c - skip over all ^ when looking for redir/pipe echo.c - when printing out, treat ^ correctly. Modified: trunk/reactos/subsys/system/cmd/cmd.c Modified: trunk/reactos/subsys/system/cmd/echo.c Modified: trunk/reactos/subsys/system/cmd/redir.c _____
Modified: trunk/reactos/subsys/system/cmd/cmd.c --- trunk/reactos/subsys/system/cmd/cmd.c 2005-08-25 19:53:37 UTC (rev 17544) +++ trunk/reactos/subsys/system/cmd/cmd.c 2005-08-25 20:05:07 UTC (rev 17545) @@ -1027,7 +1027,7 @@
cp = commandline; while (*ip) { - if (*ip == _T('%')) + if (*ip == _T('%')) { switch (*++ip) { @@ -1077,7 +1077,6 @@ GetCurrentDirectory (MAX_PATH, szPath); cp = _stpcpy (cp, szPath); } - /* %TIME% */ else if (_tcsicmp(ip,_T("time")) ==0) { @@ -1146,8 +1145,18 @@ evar = malloc ( 512 * sizeof(TCHAR)); if (evar==NULL) return 1; - + SetLastError(0); size = GetEnvironmentVariable (ip, evar, 512); + if(GetLastError() == ERROR_ENVVAR_NOT_FOUND) + { + /* if no env var is found you must + continue with what was input*/ + cp = _stpcpy (cp, _T("%")); + cp = _stpcpy (cp, ip); + cp = _stpcpy (cp, _T("%")); + } + else + { if (size > 512) { evar = realloc(evar,size * sizeof(TCHAR) ); @@ -1162,6 +1171,7 @@ { cp = _stpcpy (cp, evar); } + }
free(evar); } _____
Modified: trunk/reactos/subsys/system/cmd/echo.c --- trunk/reactos/subsys/system/cmd/echo.c 2005-08-25 19:53:37 UTC (rev 17544) +++ trunk/reactos/subsys/system/cmd/echo.c 2005-08-25 20:05:07 UTC (rev 17545) @@ -33,6 +33,7 @@
INT CommandEcho (LPTSTR cmd, LPTSTR param) { TCHAR szMsg[RC_STRING_MAX_SIZE]; + INT i = 0;
#ifdef _DEBUG DebugPrintf (_T("CommandEcho '%s' : '%s'\n"), cmd, param); @@ -58,7 +59,20 @@ else if (_tcsicmp (param, D_ON) == 0) bEcho = TRUE; else if (*param) + { + while(i < _tcslen(param)) + { + if(param[i] == _T('^')) + { + memmove(¶m[i],¶m[i + 1], _tcslen(¶m[i]) * sizeof(TCHAR)); + //skip past the char being escaped + i++; + } + else + i++; + } ConOutPuts (param); + } else { LoadString(CMD_ModuleHandle, STRING_ECHO_HELP5, szMsg, RC_STRING_MAX_SIZE); _____
Modified: trunk/reactos/subsys/system/cmd/redir.c --- trunk/reactos/subsys/system/cmd/redir.c 2005-08-25 19:53:37 UTC (rev 17544) +++ trunk/reactos/subsys/system/cmd/redir.c 2005-08-25 20:05:07 UTC (rev 17545) @@ -78,6 +78,12 @@
/* find and remove all the redirections first */ while (*sp) { + if (*sp == _T('^')) + { + *dp++ = *sp++; + *dp++ = *sp++; + continue; + } if ((*sp == _T('"')) || (*sp == _T('''))) { /* No redirects inside quotes */ @@ -242,8 +248,14 @@ sp = s; while (*sp) { - if ((*sp == _T('"')) || (*sp == _T('''))) + if (*sp == _T('^')) { + *sp++; + *sp++; + continue; + } + else if ((*sp == _T('"')) || (*sp == _T('''))) + { TCHAR qc = *sp;
do