|
|
58cf9f6 |
Patch by Thorsten Glaser <tg@mirbsd.org> for mksh <= 36, to solve
|
|
|
58cf9f6 |
some kind of "bug" resulting in command hang in mksh and also high
|
|
|
58cf9f6 |
cpu workload. For more information, please have a look to Red Hat
|
|
|
58cf9f6 |
Bugzilla ID #474115. And this patch is already in upstream version
|
|
|
58cf9f6 |
control system and will be included in upstream's next release.
|
|
|
58cf9f6 |
|
|
|
58cf9f6 |
--- mksh-36/check.t 2008-10-24 23:36:05.000000000 +0200
|
|
|
58cf9f6 |
+++ mksh-36/check.t.alias 2008-12-02 22:36:13.000000000 +0100
|
|
|
58cf9f6 |
@@ -7,7 +7,7 @@
|
|
|
58cf9f6 |
# http://www.research.att.com/~gsf/public/ifs.sh
|
|
|
58cf9f6 |
|
|
|
58cf9f6 |
expected-stdout:
|
|
|
58cf9f6 |
- @(#)MIRBSD KSH R36 2008/10/24
|
|
|
58cf9f6 |
+ @(#)MIRBSD KSH R36 2008/10/24 RedHat-1
|
|
|
58cf9f6 |
description:
|
|
|
58cf9f6 |
Check version of shell.
|
|
|
58cf9f6 |
stdin:
|
|
|
58cf9f6 |
@@ -151,6 +151,20 @@
|
|
|
58cf9f6 |
hi
|
|
|
58cf9f6 |
there
|
|
|
58cf9f6 |
---
|
|
|
58cf9f6 |
+name: alias-9
|
|
|
58cf9f6 |
+description:
|
|
|
58cf9f6 |
+ Check that recursion is detected/avoided in aliases.
|
|
|
58cf9f6 |
+time-limit: 3
|
|
|
58cf9f6 |
+stdin:
|
|
|
58cf9f6 |
+ echo -n >tf
|
|
|
58cf9f6 |
+ alias ls=ls
|
|
|
58cf9f6 |
+ ls
|
|
|
58cf9f6 |
+ echo $(ls)
|
|
|
58cf9f6 |
+ exit 0
|
|
|
58cf9f6 |
+expected-stdout:
|
|
|
58cf9f6 |
+ tf
|
|
|
58cf9f6 |
+ tf
|
|
|
58cf9f6 |
+---
|
|
|
58cf9f6 |
name: arith-lazy-1
|
|
|
58cf9f6 |
description:
|
|
|
58cf9f6 |
Check that only one side of ternary operator is evaluated
|
|
|
58cf9f6 |
--- mksh-36/lex.c 2008-10-10 23:31:05.000000000 +0200
|
|
|
58cf9f6 |
+++ mksh-36/lex.c.alias 2008-12-02 22:33:53.000000000 +0100
|
|
|
58cf9f6 |
@@ -904,16 +904,24 @@
|
|
|
58cf9f6 |
/* prefer functions over aliases */
|
|
|
58cf9f6 |
ktdelete(p);
|
|
|
58cf9f6 |
else {
|
|
|
58cf9f6 |
- Source *s;
|
|
|
58cf9f6 |
+ Source *s = source;
|
|
|
58cf9f6 |
|
|
|
58cf9f6 |
- for (s = source; s->type == SALIAS; s = s->next)
|
|
|
58cf9f6 |
+ while (s->flags & SF_HASALIAS)
|
|
|
58cf9f6 |
if (s->u.tblp == p)
|
|
|
58cf9f6 |
return LWORD;
|
|
|
58cf9f6 |
+ else
|
|
|
58cf9f6 |
+ s = s->next;
|
|
|
58cf9f6 |
/* push alias expansion */
|
|
|
58cf9f6 |
s = pushs(SALIAS, source->areap);
|
|
|
58cf9f6 |
s->start = s->str = p->val.s;
|
|
|
58cf9f6 |
s->u.tblp = p;
|
|
|
58cf9f6 |
+ s->flags |= SF_HASALIAS;
|
|
|
58cf9f6 |
s->next = source;
|
|
|
58cf9f6 |
+ if (source->type == SEOF) {
|
|
|
58cf9f6 |
+ /* prevent infinite recursion at EOS */
|
|
|
58cf9f6 |
+ source->u.tblp = p;
|
|
|
58cf9f6 |
+ source->flags |= SF_HASALIAS;
|
|
|
58cf9f6 |
+ }
|
|
|
58cf9f6 |
source = s;
|
|
|
58cf9f6 |
afree(yylval.cp, ATEMP);
|
|
|
58cf9f6 |
goto Again;
|
|
|
58cf9f6 |
--- mksh-36/sh.h 2008-10-24 23:36:06.000000000 +0200
|
|
|
58cf9f6 |
+++ mksh-36/sh.h.alias 2008-12-02 22:35:27.000000000 +0100
|
|
|
58cf9f6 |
@@ -102,7 +102,7 @@
|
|
|
58cf9f6 |
#ifdef EXTERN
|
|
|
58cf9f6 |
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.245 2008/10/24 21:35:43 tg Exp $");
|
|
|
58cf9f6 |
#endif
|
|
|
58cf9f6 |
-#define MKSH_VERSION "R36 2008/10/24"
|
|
|
58cf9f6 |
+#define MKSH_VERSION "R36 2008/10/24 RedHat-1"
|
|
|
58cf9f6 |
|
|
|
58cf9f6 |
#ifndef MKSH_INCLUDES_ONLY
|
|
|
58cf9f6 |
|
|
|
58cf9f6 |
@@ -1117,7 +1117,7 @@
|
|
|
58cf9f6 |
union {
|
|
|
58cf9f6 |
const char **strv; /* string [] */
|
|
|
58cf9f6 |
struct shf *shf; /* shell file */
|
|
|
58cf9f6 |
- struct tbl *tblp; /* alias (SALIAS) */
|
|
|
58cf9f6 |
+ struct tbl *tblp; /* alias (SF_HASALIAS) */
|
|
|
58cf9f6 |
char *freeme; /* also for SREREAD */
|
|
|
58cf9f6 |
} u;
|
|
|
58cf9f6 |
int line; /* line number */
|
|
|
58cf9f6 |
@@ -1148,6 +1148,7 @@
|
|
|
58cf9f6 |
#define SF_ALIASEND BIT(2) /* faking space at end of alias */
|
|
|
58cf9f6 |
#define SF_TTY BIT(3) /* type == SSTDIN & it is a tty */
|
|
|
58cf9f6 |
#define SF_FIRST BIT(4) /* initial state (to ignore UTF-8 BOM) */
|
|
|
58cf9f6 |
+#define SF_HASALIAS BIT(5) /* u.tblp valid (SALIAS, SEOF) */
|
|
|
58cf9f6 |
|
|
|
58cf9f6 |
typedef union {
|
|
|
58cf9f6 |
int i;
|