//config: help
//config: Enable bash-compatible extensions.
//config:
+//config:config HUSH_BRACE_EXPANSION
+//config: bool "Brace expansion"
+//config: default y
+//config: depends on HUSH_BASH_COMPAT
+//config: help
+//config: Enable {abc,def} extension.
+//config:
//config:config HUSH_HELP
//config: bool "help builtin"
//config: default y
o_addblock(o, str, strlen(str) + 1);
}
-#undef HUSH_BRACE_EXPANSION
/*
* HUSH_BRACE_EXPANSION code needs corresponding quoting on variable expansion side.
* Currently, "v='{q,w}'; echo $v" erroneously expands braces in $v.
* We have only second one.
*/
-#ifdef HUSH_BRACE_EXPANSION
+#if ENABLE_HUSH_BRACE_EXPANSION
# define MAYBE_BRACES "{}"
#else
# define MAYBE_BRACES ""
return ((int)(uintptr_t)list[n-1]) + string_start;
}
-#ifdef HUSH_BRACE_EXPANSION
+#if ENABLE_HUSH_BRACE_EXPANSION
/* There in a GNU extension, GLOB_BRACE, but it is not usable:
* first, it processes even {a} (no commas), second,
* I didn't manage to make it return strings when they don't match
static void o_addblock_duplicate_backslash(o_string *o, const char *str, int len)
{
while (--len >= 0) {
- o_addchr(o, *str);
- if (*str++ == '\\') {
+ char c = *str++;
+#if ENABLE_HUSH_BRACE_EXPANSION
+ if (c == '{' || c == '}') {
+ /* { -> \{, } -> \} */
+ o_addchr(o, '\\');
+ o_addchr(o, c);
+ continue;
+ }
+#endif
+ o_addchr(o, c);
+ if (c == '\\') {
/* \z -> \\\z; \<eol> -> \\<eol> */
o_addchr(o, '\\');
if (len) {