aboutsummaryrefslogtreecommitdiff
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
parent8e2bc47d62d48687f681855d4b086c758ae745c4 (diff)
downloadbusybox-w32-928e2a7ef437138a7b05e02be2e0f4b10123766c.tar.gz
busybox-w32-928e2a7ef437138a7b05e02be2e0f4b10123766c.tar.bz2
busybox-w32-928e2a7ef437138a7b05e02be2e0f4b10123766c.zip
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>
-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)
8383 8383
8384 TRACE(("dotrap entered\n")); 8384 TRACE(("dotrap entered\n"));
8385 for (sig = 1, g = gotsig; sig < NSIG; sig++, g++) { 8385 for (sig = 1, g = gotsig; sig < NSIG; sig++, g++) {
8386 int want_exexit;
8387 char *t; 8386 char *t;
8388 8387
8389 if (*g == 0) 8388 if (*g == 0)
@@ -8398,11 +8397,11 @@ dotrap(void)
8398 *g = 0; 8397 *g = 0;
8399 if (!t) 8398 if (!t)
8400 continue; 8399 continue;
8401 want_exexit = evalstring(t, SKIPEVAL); 8400 evalstring(t, SKIPEVAL);
8402 exitstatus = savestatus; 8401 exitstatus = savestatus;
8403 if (want_exexit) { 8402 if (evalskip) {
8404 TRACE(("dotrap returns %d\n", want_exexit)); 8403 TRACE(("dotrap returns %d\n", evalskip));
8405 return want_exexit; 8404 return evalskip;
8406 } 8405 }
8407 } 8406 }
8408 8407
@@ -9287,23 +9286,19 @@ static const struct builtincmd builtintab[] = {
9287 9286
9288/* Should match the above table! */ 9287/* Should match the above table! */
9289#define COMMANDCMD (builtintab + \ 9288#define COMMANDCMD (builtintab + \
9290 2 + \ 9289 /* . : */ 2 + \
9291 1 * ENABLE_ASH_BUILTIN_TEST + \ 9290 /* [ */ 1 * ENABLE_ASH_BUILTIN_TEST + \
9292 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \ 9291 /* [[ */ 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
9293 1 * ENABLE_ASH_ALIAS + \ 9292 /* alias */ 1 * ENABLE_ASH_ALIAS + \
9294 1 * ENABLE_ASH_JOB_CONTROL + \ 9293 /* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \
9295 3) 9294 /* break cd cddir */ 3)
9296#define EXECCMD (builtintab + \ 9295#define EVALCMD (COMMANDCMD + \
9297 2 + \ 9296 /* command */ 1 * ENABLE_ASH_CMDCMD + \
9298 1 * ENABLE_ASH_BUILTIN_TEST + \ 9297 /* continue */ 1 + \
9299 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \ 9298 /* echo */ 1 * ENABLE_ASH_BUILTIN_ECHO + \
9300 1 * ENABLE_ASH_ALIAS + \ 9299 0)
9301 1 * ENABLE_ASH_JOB_CONTROL + \ 9300#define EXECCMD (EVALCMD + \
9302 3 + \ 9301 /* eval */ 1)
9303 1 * ENABLE_ASH_CMDCMD + \
9304 1 + \
9305 ENABLE_ASH_BUILTIN_ECHO + \
9306 1)
9307 9302
9308/* 9303/*
9309 * Search the table of builtin commands. 9304 * Search the table of builtin commands.
@@ -12218,34 +12213,29 @@ evalstring(char *s, int mask)
12218{ 12213{
12219 union node *n; 12214 union node *n;
12220 struct stackmark smark; 12215 struct stackmark smark;
12221 int skip; 12216 int status;
12222// int status;
12223 12217
12224 s = sstrdup(s); 12218 s = sstrdup(s);
12225 setinputstring(s); 12219 setinputstring(s);
12226 setstackmark(&smark); 12220 setstackmark(&smark);
12227 12221
12228 skip = 0; 12222 status = 0;
12229// status = 0;
12230 while ((n = parsecmd(0)) != NODE_EOF) { 12223 while ((n = parsecmd(0)) != NODE_EOF) {
12231 int i; 12224 int i;
12232 12225
12233 i = evaltree(n, 0); 12226 i = evaltree(n, 0);
12234// if (n) 12227 if (n)
12235// status = i; 12228 status = i;
12236 popstackmark(&smark); 12229 popstackmark(&smark);
12237 skip = evalskip; 12230 if (evalskip)
12238 if (skip)
12239 break; 12231 break;
12240 } 12232 }
12241 popstackmark(&smark); 12233 popstackmark(&smark);
12242 popfile(); 12234 popfile();
12243 stunalloc(s); 12235 stunalloc(s);
12244 12236
12245 skip &= mask; 12237 evalskip &= mask;
12246 evalskip = skip; 12238 return status;
12247 return skip;
12248// return status;
12249} 12239}
12250 12240
12251/* 12241/*
@@ -12272,9 +12262,9 @@ evalcmd(int argc UNUSED_PARAM, char **argv)
12272 STPUTC('\0', concat); 12262 STPUTC('\0', concat);
12273 p = grabstackstr(concat); 12263 p = grabstackstr(concat);
12274 } 12264 }
12275 evalstring(p, ~SKIPEVAL); 12265 return evalstring(p, ~SKIPEVAL);
12276 } 12266 }
12277 return exitstatus; 12267 return 0;
12278} 12268}
12279 12269
12280/* 12270/*
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 @@
1# empty eval nevertheless sets $? = 0
2false
3eval
4echo 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 @@
1# empty eval nevertheless sets $? = 0
2false
3eval
4echo Ok:$?