aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-09-29 00:30:31 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-09-29 00:30:31 +0200
commit928e2a7ef437138a7b05e02be2e0f4b10123766c (patch)
treebb4300e101473cf94389560ee5001cabc546c99e /shell
parent8e2bc47d62d48687f681855d4b086c758ae745c4 (diff)
downloadbusybox-928e2a7ef437138a7b05e02be2e0f4b10123766c.tar.gz
ash: [EVAL] Make eval with empty arguments return 0
This is a backport of upstream commit: [EVAL] Make eval with empty arguments return 0 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c62
-rw-r--r--shell/ash_test/ash-misc/eval1.right1
-rwxr-xr-xshell/ash_test/ash-misc/eval1.tests4
-rw-r--r--shell/hush_test/hush-misc/eval1.right1
-rwxr-xr-xshell/hush_test/hush-misc/eval1.tests4
5 files changed, 36 insertions, 36 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 7a7ea1896..d0c0a510c 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8383,7 +8383,6 @@ dotrap(void)
TRACE(("dotrap entered\n"));
for (sig = 1, g = gotsig; sig < NSIG; sig++, g++) {
- int want_exexit;
char *t;
if (*g == 0)
@@ -8398,11 +8397,11 @@ dotrap(void)
*g = 0;
if (!t)
continue;
- want_exexit = evalstring(t, SKIPEVAL);
+ evalstring(t, SKIPEVAL);
exitstatus = savestatus;
- if (want_exexit) {
- TRACE(("dotrap returns %d\n", want_exexit));
- return want_exexit;
+ if (evalskip) {
+ TRACE(("dotrap returns %d\n", evalskip));
+ return evalskip;
}
}
@@ -9287,23 +9286,19 @@ static const struct builtincmd builtintab[] = {
/* Should match the above table! */
#define COMMANDCMD (builtintab + \
- 2 + \
- 1 * ENABLE_ASH_BUILTIN_TEST + \
- 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
- 1 * ENABLE_ASH_ALIAS + \
- 1 * ENABLE_ASH_JOB_CONTROL + \
- 3)
-#define EXECCMD (builtintab + \
- 2 + \
- 1 * ENABLE_ASH_BUILTIN_TEST + \
- 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
- 1 * ENABLE_ASH_ALIAS + \
- 1 * ENABLE_ASH_JOB_CONTROL + \
- 3 + \
- 1 * ENABLE_ASH_CMDCMD + \
- 1 + \
- ENABLE_ASH_BUILTIN_ECHO + \
- 1)
+ /* . : */ 2 + \
+ /* [ */ 1 * ENABLE_ASH_BUILTIN_TEST + \
+ /* [[ */ 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
+ /* alias */ 1 * ENABLE_ASH_ALIAS + \
+ /* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \
+ /* break cd cddir */ 3)
+#define EVALCMD (COMMANDCMD + \
+ /* command */ 1 * ENABLE_ASH_CMDCMD + \
+ /* continue */ 1 + \
+ /* echo */ 1 * ENABLE_ASH_BUILTIN_ECHO + \
+ 0)
+#define EXECCMD (EVALCMD + \
+ /* eval */ 1)
/*
* Search the table of builtin commands.
@@ -12218,34 +12213,29 @@ evalstring(char *s, int mask)
{
union node *n;
struct stackmark smark;
- int skip;
-// int status;
+ int status;
s = sstrdup(s);
setinputstring(s);
setstackmark(&smark);
- skip = 0;
-// status = 0;
+ status = 0;
while ((n = parsecmd(0)) != NODE_EOF) {
int i;
i = evaltree(n, 0);
-// if (n)
-// status = i;
+ if (n)
+ status = i;
popstackmark(&smark);
- skip = evalskip;
- if (skip)
+ if (evalskip)
break;
}
popstackmark(&smark);
popfile();
stunalloc(s);
- skip &= mask;
- evalskip = skip;
- return skip;
-// return status;
+ evalskip &= mask;
+ return status;
}
/*
@@ -12272,9 +12262,9 @@ evalcmd(int argc UNUSED_PARAM, char **argv)
STPUTC('\0', concat);
p = grabstackstr(concat);
}
- evalstring(p, ~SKIPEVAL);
+ return evalstring(p, ~SKIPEVAL);
}
- return exitstatus;
+ return 0;
}
/*
diff --git a/shell/ash_test/ash-misc/eval1.right b/shell/ash_test/ash-misc/eval1.right
new file mode 100644
index 000000000..7b24a35ff
--- /dev/null
+++ b/shell/ash_test/ash-misc/eval1.right
@@ -0,0 +1 @@
+Ok:0
diff --git a/shell/ash_test/ash-misc/eval1.tests b/shell/ash_test/ash-misc/eval1.tests
new file mode 100755
index 000000000..b78c6cc94
--- /dev/null
+++ b/shell/ash_test/ash-misc/eval1.tests
@@ -0,0 +1,4 @@
+# empty eval nevertheless sets $? = 0
+false
+eval
+echo Ok:$?
diff --git a/shell/hush_test/hush-misc/eval1.right b/shell/hush_test/hush-misc/eval1.right
new file mode 100644
index 000000000..7b24a35ff
--- /dev/null
+++ b/shell/hush_test/hush-misc/eval1.right
@@ -0,0 +1 @@
+Ok:0
diff --git a/shell/hush_test/hush-misc/eval1.tests b/shell/hush_test/hush-misc/eval1.tests
new file mode 100755
index 000000000..b78c6cc94
--- /dev/null
+++ b/shell/hush_test/hush-misc/eval1.tests
@@ -0,0 +1,4 @@
+# empty eval nevertheless sets $? = 0
+false
+eval
+echo Ok:$?