From 1d09a3587814b6d6e424641a6274d7877f48cd67 Mon Sep 17 00:00:00 2001 From: Thomas Faller Date: Tue, 18 Aug 2015 15:54:43 +0200 Subject: [PATCH] cmd: Implement 'echo/'. --- programs/cmd/builtins.c | 4 ++-- programs/cmd/tests/test_builtins.cmd | 8 ++++++++ programs/cmd/tests/test_builtins.cmd.exp | 16 ++++++++++++++++ programs/cmd/wcmdmain.c | 7 +++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index b1248768f23..5661c690353 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -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); diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 5351e9c1abe..0a8a4f47131 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -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@ diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 4dddc71cc86..b2221588c3b 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -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@ diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 1e42c477778..7666329a0f3 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -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); }