cmd: Echo back command with whitespace removed first.

This commit is contained in:
Jason Edmeades 2012-09-25 22:05:03 +01:00 committed by Alexandre Julliard
parent 2ff533c1f2
commit a810e41e47
3 changed files with 24 additions and 7 deletions

View File

@ -30,6 +30,9 @@ echo @tab@ on @space@
@echo off
echo off@tab@@space@
@echo noecho1
@echo noecho2
@@@@@echo echo3
echo ------------ Testing 'echo' [OFF] ------------
echo word
echo 'singlequotedword'
@ -324,6 +327,8 @@ set VAR=
echo ------------ Testing variable substitution ------------
echo --- in FOR variables
for %%i in ("A B" C) do echo %%i
rem check works when prefix with @
@for %%i in ("A B" C) do echo %%i
rem quotes removal
for %%i in ("A B" C) do echo '%%~i'
rem fully qualified path

View File

@ -51,7 +51,7 @@ word@space@
@pwd@>echo word@space@@space@@space@
word@space@@space@
@todo_wine@@pwd@>echo word@space@
@pwd@>echo word@space@
word
@pwd@>echo@tab@word@space@
@ -63,7 +63,7 @@ word@space@@tab@
@pwd@>echo@tab@word@tab@@space@@space@
word@tab@@space@
@todo_wine@@pwd@>echo word@space@
@pwd@>echo word@space@
word
@pwd@>echo@space@@tab@word@space@
@ -76,6 +76,9 @@ word
@tab@word
@pwd@>echo @tab@ on @space@@space@
noecho1
noecho2
echo3
------------ Testing 'echo' [OFF] ------------
word
'singlequotedword'
@ -282,6 +285,8 @@ r@or_broken@qwerty
--- in FOR variables
"A B"
C
"A B"
C
'A B'@or_broken@''
'C'@or_broken@''
@pwd@\C D@or_broken@%~ff

View File

@ -1819,27 +1819,34 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Replace env vars if in a batch context */
if (context) handleExpansion(extraSpace, FALSE, NULL, NULL);
/* Skip preceeding whitespace */
while (*curPos == ' ' || *curPos == '\t') curPos++;
/* Show prompt before batch line IF echo is on and in batch program */
if (context && echo_mode && extraSpace[0] && (extraSpace[0] != '@')) {
if (context && echo_mode && *curPos && (*curPos != '@')) {
static const WCHAR echoDot[] = {'e','c','h','o','.'};
static const WCHAR echoCol[] = {'e','c','h','o',':'};
const DWORD len = sizeof(echoDot)/sizeof(echoDot[0]);
DWORD curr_size = strlenW(extraSpace);
DWORD curr_size = strlenW(curPos);
DWORD min_len = (curr_size < len ? curr_size : len);
WCMD_show_prompt();
WCMD_output_asis(extraSpace);
WCMD_output_asis(curPos);
/* I don't know why Windows puts a space here but it does */
/* Except for lines starting with 'echo.' or 'echo:'. Ask MS why */
if (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
extraSpace, min_len, echoDot, len) != CSTR_EQUAL
curPos, min_len, echoDot, len) != CSTR_EQUAL
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
extraSpace, min_len, echoCol, len) != CSTR_EQUAL)
curPos, min_len, echoCol, len) != CSTR_EQUAL)
{
WCMD_output_asis(spaceW);
}
WCMD_output_asis(newlineW);
}
/* Skip repeated 'no echo' characters */
while (*curPos == '@') curPos++;
/* Start with an empty string, copying to the command string */
curStringLen = 0;
curRedirsLen = 0;