Feature flag support for ? wildcard

This partially reverts 6e56637cf0 and #4520
by bringing back the ? wildcard, guarded by the qmark-noglob feature flag.
This commit is contained in:
ridiculousfish
2018-05-05 19:11:57 -07:00
parent dc8d603f98
commit 762c31be87
13 changed files with 117 additions and 41 deletions

View File

@@ -933,6 +933,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
const bool no_quoted = static_cast<bool>(flags & ESCAPE_NO_QUOTED);
const bool no_tilde = static_cast<bool>(flags & ESCAPE_NO_TILDE);
const bool no_caret = fish_features().test(features_t::stderr_nocaret);
const bool no_qmark = fish_features().test(features_t::qmark_noglob);
int need_escape = 0;
int need_complex_escape = 0;
@@ -997,6 +998,11 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
out += *in;
break;
}
case ANY_CHAR: {
// See #1614
out += L'?';
break;
}
case ANY_STRING: {
out += L'*';
break;
@@ -1019,12 +1025,13 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
case L']':
case L'{':
case L'}':
case L'?':
case L'*':
case L'|':
case L';':
case L'"':
case L'~': {
bool char_is_normal = (c == L'~' && no_tilde) || (c == L'^' && no_caret);
bool char_is_normal = (c == L'~' && no_tilde) || (c == L'^' && no_caret) || (c == L'?' && no_qmark);
if (!char_is_normal) {
need_escape = 1;
if (escape_all) out += L'\\';
@@ -1353,6 +1360,12 @@ static bool unescape_string_internal(const wchar_t *const input, const size_t in
}
break;
}
case L'?': {
if (unescape_special && !fish_features().test(features_t::qmark_noglob)) {
to_append_or_none = ANY_CHAR;
}
break;
}
case L'$': {
if (unescape_special) {
to_append_or_none = VARIABLE_EXPAND;