bring back ${ foo;} sans dot.mkshrc patch, using a temporary file, and as experimental feature

This commit is contained in:
tg
2012-10-22 20:19:18 +00:00
parent 574c024635
commit bfe7d78d40
9 changed files with 177 additions and 37 deletions

33
lex.c
View File

@@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.168 2012/10/03 17:24:20 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.169 2012/10/22 20:19:13 tg Exp $");
/*
* states while lexing word
@@ -109,7 +109,7 @@ void yyskiputf8bom(void);
static int backslash_skip;
static int ignore_backslash_newline;
static struct sretrace_info *retrace_info;
uint8_t subshell_nesting_level = 0;
int subshell_nesting_type = 0;
/* optimised getsc_bn() */
#define o_getsc() (*source->str != '\0' && *source->str != '\\' && \
@@ -262,6 +262,13 @@ yylex(int cf)
while (!((c = getsc()) == 0 ||
((state == SBASE || state == SHEREDELIM || state == SHERESTRING) &&
ctype(c, C_LEX1)))) {
#ifndef MKSH_DISABLE_EXPERIMENTAL
if (state == SBASE &&
subshell_nesting_type == /*{*/ '}' &&
c == /*{*/ '}')
/* possibly end ${ :;} */
break;
#endif
accept_nonword:
Xcheck(ws, wp);
switch (state) {
@@ -395,14 +402,30 @@ yylex(int cf)
} else {
ungetsc(c);
subst_command:
sp = yyrecursive();
c = COMSUB;
#ifndef MKSH_DISABLE_EXPERIMENTAL
subst_command2:
#endif
sp = yyrecursive(c);
cz = strlen(sp) + 1;
XcheckN(ws, wp, cz);
*wp++ = COMSUB;
*wp++ = c;
memcpy(wp, sp, cz);
wp += cz;
}
} else if (c == '{') /*}*/ {
#ifndef MKSH_DISABLE_EXPERIMENTAL
c = getsc();
if (ctype(c, C_IFSWS)) {
/*
* non-subenvironment
* "command" substitution
*/
c = FUNSUB;
goto subst_command2;
}
ungetsc(c);
#endif
*wp++ = OSUBST;
*wp++ = '{'; /*}*/
wp = get_brace_var(&ws, wp);
@@ -1171,7 +1194,7 @@ readhere(struct ioword *iop)
/* end of here document marker, what to do? */
switch (c) {
case /*(*/ ')':
if (!subshell_nesting_level)
if (!subshell_nesting_type)
/*-
* not allowed outside $(...) or (...)
* => mismatch