mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
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. svn path=/trunk/; revision=17545
This commit is contained in:
parent
011639b626
commit
c7b88afc3f
3 changed files with 40 additions and 4 deletions
|
@ -1027,7 +1027,7 @@ ProcessInput (BOOL bFlag)
|
|||
cp = commandline;
|
||||
while (*ip)
|
||||
{
|
||||
if (*ip == _T('%'))
|
||||
if (*ip == _T('%'))
|
||||
{
|
||||
switch (*++ip)
|
||||
{
|
||||
|
@ -1077,7 +1077,6 @@ ProcessInput (BOOL bFlag)
|
|||
GetCurrentDirectory (MAX_PATH, szPath);
|
||||
cp = _stpcpy (cp, szPath);
|
||||
}
|
||||
|
||||
/* %TIME% */
|
||||
else if (_tcsicmp(ip,_T("time")) ==0)
|
||||
{
|
||||
|
@ -1146,8 +1145,18 @@ ProcessInput (BOOL bFlag)
|
|||
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 @@ ProcessInput (BOOL bFlag)
|
|||
{
|
||||
cp = _stpcpy (cp, evar);
|
||||
}
|
||||
}
|
||||
|
||||
free(evar);
|
||||
}
|
||||
|
|
|
@ -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 @@ INT CommandEcho (LPTSTR cmd, LPTSTR param)
|
|||
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);
|
||||
|
|
|
@ -78,6 +78,12 @@ INT GetRedirection (LPTSTR s, LPTSTR ifn, LPTSTR ofn, LPTSTR efn, LPINT lpnFlags
|
|||
/* 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,7 +248,13 @@ INT GetRedirection (LPTSTR s, LPTSTR ifn, LPTSTR ofn, LPTSTR efn, LPINT lpnFlags
|
|||
sp = s;
|
||||
while (*sp)
|
||||
{
|
||||
if ((*sp == _T('"')) || (*sp == _T('\'')))
|
||||
if (*sp == _T('^'))
|
||||
{
|
||||
*sp++;
|
||||
*sp++;
|
||||
continue;
|
||||
}
|
||||
else if ((*sp == _T('"')) || (*sp == _T('\'')))
|
||||
{
|
||||
TCHAR qc = *sp;
|
||||
|
||||
|
|
Loading…
Reference in a new issue