cmd: Implement 'echo/'.

This commit is contained in:
Thomas Faller 2015-08-18 15:54:43 +02:00 committed by Alexandre Julliard
parent 21a14e9612
commit 1d09a35878
4 changed files with 31 additions and 4 deletions

View File

@ -1465,7 +1465,7 @@ void WCMD_echo (const WCHAR *args)
WCHAR *trimmed;
if ( args[0]==' ' || args[0]=='\t' || args[0]=='.'
|| args[0]==':' || args[0]==';')
|| args[0]==':' || args[0]==';' || args[0]=='/')
args++;
trimmed = WCMD_strtrim(args);
@ -1473,7 +1473,7 @@ void WCMD_echo (const WCHAR *args)
count = strlenW(trimmed);
if (count == 0 && origcommand[0]!='.' && origcommand[0]!=':'
&& origcommand[0]!=';') {
&& origcommand[0]!=';' && origcommand[0]!='/') {
if (echo_mode) WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), onW);
else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), offW);
heap_free(trimmed);

View File

@ -15,6 +15,10 @@ echo:
echo :
echo:word
echo :word
echo/
echo /
echo/word
echo /word
echo off now
echo word@space@
echo word@space@@space@
@ -47,6 +51,10 @@ echo:
echo :
echo:word
echo :word
echo/
echo /
echo/word
echo /word
echo on again
echo word@space@
echo word@space@@space@

View File

@ -42,6 +42,18 @@ word
@pwd@>echo :word@space@
:word
@pwd@>echo/
@pwd@>echo /@space@
/
@pwd@>echo/word
word
@pwd@>echo /word@space@
/word
@pwd@>echo off now@space@
off now
@ -93,6 +105,10 @@ word
:
word
:word
/
word
/word
on again
word@space@
word@space@@space@

View File

@ -1853,17 +1853,20 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
if (context && echo_mode && *curPos && (*curPos != '@')) {
static const WCHAR echoDot[] = {'e','c','h','o','.'};
static const WCHAR echoCol[] = {'e','c','h','o',':'};
static const WCHAR echoSlash[] = {'e','c','h','o','/'};
const DWORD len = sizeof(echoDot)/sizeof(echoDot[0]);
DWORD curr_size = strlenW(curPos);
DWORD min_len = (curr_size < len ? curr_size : len);
WCMD_show_prompt();
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 */
/* Except for lines starting with 'echo.', 'echo:' or 'echo/'. Ask MS why */
if (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
curPos, min_len, echoDot, len) != CSTR_EQUAL
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
curPos, min_len, echoCol, len) != CSTR_EQUAL)
curPos, min_len, echoCol, len) != CSTR_EQUAL
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
curPos, min_len, echoSlash, len) != CSTR_EQUAL)
{
WCMD_output_asis(spaceW);
}