From 01d8490255764855fbf4d3e39995d061b3e69bfe Mon Sep 17 00:00:00 2001 From: maxfl Date: Mon, 2 Jul 2012 11:52:18 +0800 Subject: [PATCH] Return the previous logic for '\\'. The following expression now works: ```sh switch '\\' case '\\' echo 1 end ``` Due to ambiguity, the following expression also works: ```sh switch '\a' case '\\a' echo 1 end ``` By the way, the following expression now doesn't work, which was not the case before, because of wrong escaping: ```sh switch 'nn' case '\n' echo 1 end ``` --- parse_util.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/parse_util.cpp b/parse_util.cpp index c9c7f548c..e474b4df4 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -660,11 +660,28 @@ wchar_t *parse_util_unescape_wildcards( const wchar_t *str ) { case L'\\': { - if( *(in+1) ) - { - in++; - *(out++)=*in; - } + switch ( *(in + 1) ) + { + case L'*': + case L'?': + { + in++; + *(out++)=*in; + break; + } + case L'\\': + { + in++; + *(out++)=L'\\'; + *(out++)=L'\\'; + break; + } + default: + { + *(out++)=*in; + break; + } + } break; }