MKSH_DISABLE_EXPERIMENTAL is a NOP again; use ${ precmd;} in dot.mkshrc

This commit is contained in:
tg 2012-11-30 20:19:16 +00:00
parent f63bcae02c
commit 0f3071a8b2
9 changed files with 21 additions and 50 deletions

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.590 2012/11/20 18:50:41 tg Exp $' srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.591 2012/11/30 20:19:09 tg Exp $'
#- #-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 # 2011, 2012
@ -1370,9 +1370,9 @@ ac_ifcpp 'ifdef MKSH_CONSERVATIVE_FDS' isset_MKSH_CONSERVATIVE_FDS '' \
#ac_ifcpp 'ifdef MKSH_DISABLE_DEPRECATED' isset_MKSH_DISABLE_DEPRECATED '' \ #ac_ifcpp 'ifdef MKSH_DISABLE_DEPRECATED' isset_MKSH_DISABLE_DEPRECATED '' \
# "if deprecated features are to be omitted" && \ # "if deprecated features are to be omitted" && \
# check_categories="$check_categories nodeprecated" # check_categories="$check_categories nodeprecated"
ac_ifcpp 'ifdef MKSH_DISABLE_EXPERIMENTAL' isset_MKSH_DISABLE_EXPERIMENTAL '' \ #ac_ifcpp 'ifdef MKSH_DISABLE_EXPERIMENTAL' isset_MKSH_DISABLE_EXPERIMENTAL '' \
"if experimental features are to be omitted" && \ # "if experimental features are to be omitted" && \
check_categories="$check_categories noexperimental" # check_categories="$check_categories noexperimental"
# #
# Environment: headers # Environment: headers
@ -1495,7 +1495,7 @@ else
#define EXTERN #define EXTERN
#define MKSH_INCLUDES_ONLY #define MKSH_INCLUDES_ONLY
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.590 2012/11/20 18:50:41 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.591 2012/11/30 20:19:09 tg Exp $");
int main(void) { printf("Hello, World!\n"); return (0); } int main(void) { printf("Hello, World!\n"); return (0); }
EOF EOF
case $cm in case $cm in

@ -1,5 +1,5 @@
# $Id$ # $Id$
# $MirOS: src/bin/mksh/dot.mkshrc,v 1.72 2012/10/30 21:04:56 tg Exp $ # $MirOS: src/bin/mksh/dot.mkshrc,v 1.73 2012/11/30 20:19:10 tg Exp $
#- #-
# Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010, # Copyright (c) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 # 2011, 2012
@ -30,7 +30,7 @@ function precmd {
(( e )) && print -n "$e|" (( e )) && print -n "$e|"
} }
PS1=$'\001\r''$(precmd)${USER:=$(ulimit -c 0; id -un 2>/dev/null || echo \? PS1=$'\001\r''${ precmd;}${USER:=$(ulimit -c 0; id -un 2>/dev/null || echo \?
)}@${HOSTNAME%%.*}:$(local d=${PWD:-?} p=~; [[ $p = ?(*/) ]] || \ )}@${HOSTNAME%%.*}:$(local d=${PWD:-?} p=~; [[ $p = ?(*/) ]] || \
d=${d/#$p/~}; local m=${%d} n p=...; (( m > 0 )) || m=${#d} d=${d/#$p/~}; local m=${%d} n p=...; (( m > 0 )) || m=${#d}
(( m > (n = (COLUMNS/3 < 7 ? 7 : COLUMNS/3)) )) && d=${d:(-n)} || \ (( m > (n = (COLUMNS/3 < 7 ? 7 : COLUMNS/3)) )) && d=${d:(-n)} || \

10
eval.c

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.129 2012/10/22 20:19:12 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.130 2012/11/30 20:19:11 tg Exp $");
/* /*
* string expansion * string expansion
@ -277,30 +277,24 @@ expand(const char *cp, /* input word */
quote = st->quotew; quote = st->quotew;
continue; continue;
case COMSUB: case COMSUB:
#ifndef MKSH_DISABLE_EXPERIMENTAL
case FUNSUB: case FUNSUB:
#endif
tilde_ok = 0; tilde_ok = 0;
if (f & DONTRUNCOMMAND) { if (f & DONTRUNCOMMAND) {
word = IFS_WORD; word = IFS_WORD;
*dp++ = '$'; *dp++ = '$';
#ifndef MKSH_DISABLE_EXPERIMENTAL
if (c == FUNSUB) { if (c == FUNSUB) {
*dp++ = '{'; *dp++ = '{';
*dp++ = ' '; *dp++ = ' ';
} else } else
#endif
*dp++ = '('; *dp++ = '(';
while (*sp != '\0') { while (*sp != '\0') {
Xcheck(ds, dp); Xcheck(ds, dp);
*dp++ = *sp++; *dp++ = *sp++;
} }
#ifndef MKSH_DISABLE_EXPERIMENTAL
if (c == FUNSUB) { if (c == FUNSUB) {
*dp++ = ';'; *dp++ = ';';
*dp++ = '}'; *dp++ = '}';
} else } else
#endif
*dp++ = ')'; *dp++ = ')';
} else { } else {
type = comsub(&x, sp, c); type = comsub(&x, sp, c);
@ -1322,7 +1316,6 @@ comsub(Expand *xp, const char *cp, int fn MKSH_A_UNUSED)
SHF_MAPHI|SHF_CLEXEC); SHF_MAPHI|SHF_CLEXEC);
if (shf == NULL) if (shf == NULL)
errorf("%s: %s %s", name, "can't open", "$() input"); errorf("%s: %s %s", name, "can't open", "$() input");
#ifndef MKSH_DISABLE_EXPERIMENTAL
} else if (fn == FUNSUB) { } else if (fn == FUNSUB) {
int ofd1; int ofd1;
struct temp *tf = NULL; struct temp *tf = NULL;
@ -1345,7 +1338,6 @@ comsub(Expand *xp, const char *cp, int fn MKSH_A_UNUSED)
shf = shf_open(tf->tffn, O_RDONLY, 0, SHF_MAPHI | SHF_CLEXEC); shf = shf_open(tf->tffn, O_RDONLY, 0, SHF_MAPHI | SHF_CLEXEC);
unlink(tf->tffn); unlink(tf->tffn);
afree(tf, ATEMP); afree(tf, ATEMP);
#endif
} else { } else {
int ofd1, pv[2]; int ofd1, pv[2];

6
exec.c

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.106 2012/11/30 19:02:06 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.107 2012/11/30 20:19:11 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL #ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh" #define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -605,7 +605,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
/* go on, use the builtin */ /* go on, use the builtin */
break; break;
#endif #endif
#if !defined(MKSH_SMALL) && !defined(MKSH_DISABLE_EXPERIMENTAL) #if !defined(MKSH_SMALL)
} else if (tp->val.f == c_trap) { } else if (tp->val.f == c_trap) {
t->u.evalflags &= ~DOTCOMEXEC; t->u.evalflags &= ~DOTCOMEXEC;
break; break;
@ -614,7 +614,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
break; break;
tp = findcom(ap[0], fcflags & (FC_BI|FC_FUNC)); tp = findcom(ap[0], fcflags & (FC_BI|FC_FUNC));
} }
#if !defined(MKSH_SMALL) && !defined(MKSH_DISABLE_EXPERIMENTAL) #if !defined(MKSH_SMALL)
if (t->u.evalflags & DOTCOMEXEC) if (t->u.evalflags & DOTCOMEXEC)
flags |= XEXEC; flags |= XEXEC;
#endif #endif

8
lex.c

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.171 2012/11/30 19:02:08 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.172 2012/11/30 20:19:12 tg Exp $");
/* /*
* states while lexing word * states while lexing word
@ -262,13 +262,11 @@ yylex(int cf)
while (!((c = getsc()) == 0 || while (!((c = getsc()) == 0 ||
((state == SBASE || state == SHEREDELIM || state == SHERESTRING) && ((state == SBASE || state == SHEREDELIM || state == SHERESTRING) &&
ctype(c, C_LEX1)))) { ctype(c, C_LEX1)))) {
#ifndef MKSH_DISABLE_EXPERIMENTAL
if (state == SBASE && if (state == SBASE &&
subshell_nesting_type == /*{*/ '}' && subshell_nesting_type == /*{*/ '}' &&
c == /*{*/ '}') c == /*{*/ '}')
/* possibly end ${ :;} */ /* possibly end ${ :;} */
break; break;
#endif
accept_nonword: accept_nonword:
Xcheck(ws, wp); Xcheck(ws, wp);
switch (state) { switch (state) {
@ -403,9 +401,7 @@ yylex(int cf)
ungetsc(c); ungetsc(c);
subst_command: subst_command:
c = COMSUB; c = COMSUB;
#ifndef MKSH_DISABLE_EXPERIMENTAL
subst_command2: subst_command2:
#endif
sp = yyrecursive(c); sp = yyrecursive(c);
cz = strlen(sp) + 1; cz = strlen(sp) + 1;
XcheckN(ws, wp, cz); XcheckN(ws, wp, cz);
@ -414,7 +410,6 @@ yylex(int cf)
wp += cz; wp += cz;
} }
} else if (c == '{') /*}*/ { } else if (c == '{') /*}*/ {
#ifndef MKSH_DISABLE_EXPERIMENTAL
c = getsc(); c = getsc();
if (ctype(c, C_IFSWS)) { if (ctype(c, C_IFSWS)) {
/* /*
@ -425,7 +420,6 @@ yylex(int cf)
goto subst_command2; goto subst_command2;
} }
ungetsc(c); ungetsc(c);
#endif
*wp++ = OSUBST; *wp++ = OSUBST;
*wp++ = '{'; /*}*/ *wp++ = '{'; /*}*/
wp = get_brace_var(&ws, wp); wp = get_brace_var(&ws, wp);

8
main.c

@ -34,7 +34,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.245 2012/11/30 19:58:47 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.246 2012/11/30 20:19:13 tg Exp $");
extern char **environ; extern char **environ;
@ -460,7 +460,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
s = pushs(SSTRINGCMDLINE, ATEMP); s = pushs(SSTRINGCMDLINE, ATEMP);
if (!(s->start = s->str = argv[argi++])) if (!(s->start = s->str = argv[argi++]))
errorf("%s %s", "-c", "requires an argument"); errorf("%s %s", "-c", "requires an argument");
#if !defined(MKSH_SMALL) && !defined(MKSH_DISABLE_EXPERIMENTAL) #if !defined(MKSH_SMALL)
while (*s->str) { while (*s->str) {
if (*s->str != ' ' && ctype(*s->str, C_QUOTE)) if (*s->str != ' ' && ctype(*s->str, C_QUOTE))
break; break;
@ -849,7 +849,7 @@ shell(Source * volatile s, volatile bool toplevel)
break; break;
} }
} }
#if !defined(MKSH_SMALL) && !defined(MKSH_DISABLE_EXPERIMENTAL) #if !defined(MKSH_SMALL)
else if ((s->flags & SF_MAYEXEC) && t->type == TCOM) else if ((s->flags & SF_MAYEXEC) && t->type == TCOM)
t->u.evalflags |= DOTCOMEXEC; t->u.evalflags |= DOTCOMEXEC;
#endif #endif
@ -1593,7 +1593,6 @@ maketemp(Area *ap, Temp_type type, struct temp **tlist)
/* do another cycle */ /* do another cycle */
} }
#ifndef MKSH_DISABLE_EXPERIMENTAL
if (type == TT_FUNSUB) { if (type == TT_FUNSUB) {
int nfd; int nfd;
@ -1603,7 +1602,6 @@ maketemp(Area *ap, Temp_type type, struct temp **tlist)
i = nfd; i = nfd;
} }
} }
#endif
/* shf_fdopen cannot fail, so no fd leak */ /* shf_fdopen cannot fail, so no fd leak */
tp->shf = shf_fdopen(i, SHF_WR, NULL); tp->shf = shf_fdopen(i, SHF_WR, NULL);

10
sh.h

@ -157,7 +157,7 @@
#endif #endif
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.608 2012/11/30 19:58:48 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.609 2012/11/30 20:19:14 tg Exp $");
#endif #endif
#define MKSH_VERSION "R41 2012/11/30" #define MKSH_VERSION "R41 2012/11/30"
@ -785,10 +785,8 @@ typedef uint8_t Temp_type;
#define TT_HEREDOC_EXP 0 #define TT_HEREDOC_EXP 0
/* temporary file used for history editing (fc -e) */ /* temporary file used for history editing (fc -e) */
#define TT_HIST_EDIT 1 #define TT_HIST_EDIT 1
#ifndef MKSH_DISABLE_EXPERIMENTAL
/* temporary file used during in-situ command substitution */ /* temporary file used during in-situ command substitution */
#define TT_FUNSUB 2 #define TT_FUNSUB 2
#endif
/* temp/heredoc files. The file is removed when the struct is freed. */ /* temp/heredoc files. The file is removed when the struct is freed. */
struct temp { struct temp {
@ -1300,9 +1298,7 @@ struct op {
#define SPAT 10 /* separate pattern: | */ #define SPAT 10 /* separate pattern: | */
#define CPAT 11 /* close pattern: ) */ #define CPAT 11 /* close pattern: ) */
#define ADELIM 12 /* arbitrary delimiter: ${foo:2:3} ${foo/bar/baz} */ #define ADELIM 12 /* arbitrary delimiter: ${foo:2:3} ${foo/bar/baz} */
#ifndef MKSH_DISABLE_EXPERIMENTAL
#define FUNSUB 14 /* ${ foo;} substitution (NUL terminated) */ #define FUNSUB 14 /* ${ foo;} substitution (NUL terminated) */
#endif
/* /*
* IO redirection * IO redirection
@ -1361,7 +1357,7 @@ struct ioword {
#define DOTEMP BIT(8) /* dito: in word part of ${..[%#=?]..} */ #define DOTEMP BIT(8) /* dito: in word part of ${..[%#=?]..} */
#define DOVACHECK BIT(9) /* var assign check (for typeset, set, etc) */ #define DOVACHECK BIT(9) /* var assign check (for typeset, set, etc) */
#define DOMARKDIRS BIT(10) /* force markdirs behaviour */ #define DOMARKDIRS BIT(10) /* force markdirs behaviour */
#if !defined(MKSH_SMALL) && !defined(MKSH_DISABLE_EXPERIMENTAL) #if !defined(MKSH_SMALL)
#define DOTCOMEXEC BIT(11) /* not an eval flag, used by sh -c hack */ #define DOTCOMEXEC BIT(11) /* not an eval flag, used by sh -c hack */
#endif #endif
@ -1507,7 +1503,7 @@ struct source {
#define SF_ALIASEND BIT(2) /* faking space at end of alias */ #define SF_ALIASEND BIT(2) /* faking space at end of alias */
#define SF_TTY BIT(3) /* type == SSTDIN & it is a tty */ #define SF_TTY BIT(3) /* type == SSTDIN & it is a tty */
#define SF_HASALIAS BIT(4) /* u.tblp valid (SALIAS, SEOF) */ #define SF_HASALIAS BIT(4) /* u.tblp valid (SALIAS, SEOF) */
#if !defined(MKSH_SMALL) && !defined(MKSH_DISABLE_EXPERIMENTAL) #if !defined(MKSH_SMALL)
#define SF_MAYEXEC BIT(5) /* special sh -c optimisation hack */ #define SF_MAYEXEC BIT(5) /* special sh -c optimisation hack */
#endif #endif

7
syn.c

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.84 2012/10/30 20:49:44 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/syn.c,v 1.85 2012/11/30 20:19:15 tg Exp $");
extern int subshell_nesting_type; extern int subshell_nesting_type;
extern void yyskiputf8bom(void); extern void yyskiputf8bom(void);
@ -1134,13 +1134,10 @@ yyrecursive(int subtype MKSH_A_UNUSED)
struct yyrecursive_state *ys; struct yyrecursive_state *ys;
int stok, etok; int stok, etok;
#ifndef MKSH_DISABLE_EXPERIMENTAL
if (subtype == FUNSUB) { if (subtype == FUNSUB) {
stok = '{'; stok = '{';
etok = '}'; etok = '}';
} else } else {
#endif
{
stok = '('; stok = '(';
etok = ')'; etok = ')';
} }

8
tree.c

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.65 2012/10/22 20:19:18 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/tree.c,v 1.66 2012/11/30 20:19:16 tg Exp $");
#define INDENT 8 #define INDENT 8
@ -342,12 +342,10 @@ wdvarput(struct shf *shf, const char *wp, int quotelevel, int opmode)
shf_putc(c, shf); shf_putc(c, shf);
shf_puts(cs, shf); shf_puts(cs, shf);
break; break;
#ifndef MKSH_DISABLE_EXPERIMENTAL
case FUNSUB: case FUNSUB:
shf_puts("${ ", shf); shf_puts("${ ", shf);
cs = ";}"; cs = ";}";
goto pSUB; goto pSUB;
#endif
case EXPRSUB: case EXPRSUB:
shf_puts("$((", shf); shf_puts("$((", shf);
cs = "))"; cs = "))";
@ -587,9 +585,7 @@ wdscan(const char *wp, int c)
wp++; wp++;
break; break;
case COMSUB: case COMSUB:
#ifndef MKSH_DISABLE_EXPERIMENTAL
case FUNSUB: case FUNSUB:
#endif
case EXPRSUB: case EXPRSUB:
while (*wp++ != 0) while (*wp++ != 0)
; ;
@ -829,11 +825,9 @@ dumpwdvar_i(struct shf *shf, const char *wp, int quotelevel)
closeandout: closeandout:
shf_putc('>', shf); shf_putc('>', shf);
break; break;
#ifndef MKSH_DISABLE_EXPERIMENTAL
case FUNSUB: case FUNSUB:
shf_puts("FUNSUB<", shf); shf_puts("FUNSUB<", shf);
goto dumpsub; goto dumpsub;
#endif
case EXPRSUB: case EXPRSUB:
shf_puts("EXPRSUB<", shf); shf_puts("EXPRSUB<", shf);
goto dumpsub; goto dumpsub;