From d0c85471b40fee548efc35a370f5d5c4b656f66a Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 16 Aug 2014 19:25:36 -0700 Subject: [PATCH] Make escape_string transform wildcard characters The characters ANY_CHAR, ANY_STRING, and ANY_STRING_RECURSIVE are currently transformed by unescape, but not by escape. Let's try escaping them. Fixes #1614. --- common.cpp | 15 +++++++++++++++ complete.cpp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/common.cpp b/common.cpp index 001eab0fc..b8a2661d2 100644 --- a/common.cpp +++ b/common.cpp @@ -1019,7 +1019,22 @@ static void escape_string_internal(const wchar_t *orig_in, size_t in_len, wcstri out += *in; break; } + + + // Experimental fix for #1614 + // The hope is that any time these appear in a string, they came from wildcard expansion + case ANY_CHAR: + out += L'?'; + break; + case ANY_STRING: + out += L'*'; + break; + + case ANY_STRING_RECURSIVE: + out += L"**"; + break; + case L'&': case L'$': case L' ': diff --git a/complete.cpp b/complete.cpp index c6f185be7..d7ecdf73e 100644 --- a/complete.cpp +++ b/complete.cpp @@ -2096,7 +2096,7 @@ void complete_print(wcstring &out) append_switch(out, e->cmd_is_path ? L"path" : L"command", - e->cmd); + escape_string(e->cmd, ESCAPE_ALL)); if (o->short_opt != 0)