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>
This commit is contained in:
parent
8e2bc47d62
commit
928e2a7ef4
62
shell/ash.c
62
shell/ash.c
@ -8383,7 +8383,6 @@ dotrap(void)
|
|||||||
|
|
||||||
TRACE(("dotrap entered\n"));
|
TRACE(("dotrap entered\n"));
|
||||||
for (sig = 1, g = gotsig; sig < NSIG; sig++, g++) {
|
for (sig = 1, g = gotsig; sig < NSIG; sig++, g++) {
|
||||||
int want_exexit;
|
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
if (*g == 0)
|
if (*g == 0)
|
||||||
@ -8398,11 +8397,11 @@ dotrap(void)
|
|||||||
*g = 0;
|
*g = 0;
|
||||||
if (!t)
|
if (!t)
|
||||||
continue;
|
continue;
|
||||||
want_exexit = evalstring(t, SKIPEVAL);
|
evalstring(t, SKIPEVAL);
|
||||||
exitstatus = savestatus;
|
exitstatus = savestatus;
|
||||||
if (want_exexit) {
|
if (evalskip) {
|
||||||
TRACE(("dotrap returns %d\n", want_exexit));
|
TRACE(("dotrap returns %d\n", evalskip));
|
||||||
return want_exexit;
|
return evalskip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9287,23 +9286,19 @@ static const struct builtincmd builtintab[] = {
|
|||||||
|
|
||||||
/* Should match the above table! */
|
/* Should match the above table! */
|
||||||
#define COMMANDCMD (builtintab + \
|
#define COMMANDCMD (builtintab + \
|
||||||
2 + \
|
/* . : */ 2 + \
|
||||||
1 * ENABLE_ASH_BUILTIN_TEST + \
|
/* [ */ 1 * ENABLE_ASH_BUILTIN_TEST + \
|
||||||
1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
|
/* [[ */ 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
|
||||||
1 * ENABLE_ASH_ALIAS + \
|
/* alias */ 1 * ENABLE_ASH_ALIAS + \
|
||||||
1 * ENABLE_ASH_JOB_CONTROL + \
|
/* bg */ 1 * ENABLE_ASH_JOB_CONTROL + \
|
||||||
3)
|
/* break cd cddir */ 3)
|
||||||
#define EXECCMD (builtintab + \
|
#define EVALCMD (COMMANDCMD + \
|
||||||
2 + \
|
/* command */ 1 * ENABLE_ASH_CMDCMD + \
|
||||||
1 * ENABLE_ASH_BUILTIN_TEST + \
|
/* continue */ 1 + \
|
||||||
1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
|
/* echo */ 1 * ENABLE_ASH_BUILTIN_ECHO + \
|
||||||
1 * ENABLE_ASH_ALIAS + \
|
0)
|
||||||
1 * ENABLE_ASH_JOB_CONTROL + \
|
#define EXECCMD (EVALCMD + \
|
||||||
3 + \
|
/* eval */ 1)
|
||||||
1 * ENABLE_ASH_CMDCMD + \
|
|
||||||
1 + \
|
|
||||||
ENABLE_ASH_BUILTIN_ECHO + \
|
|
||||||
1)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search the table of builtin commands.
|
* Search the table of builtin commands.
|
||||||
@ -12218,34 +12213,29 @@ evalstring(char *s, int mask)
|
|||||||
{
|
{
|
||||||
union node *n;
|
union node *n;
|
||||||
struct stackmark smark;
|
struct stackmark smark;
|
||||||
int skip;
|
int status;
|
||||||
// int status;
|
|
||||||
|
|
||||||
s = sstrdup(s);
|
s = sstrdup(s);
|
||||||
setinputstring(s);
|
setinputstring(s);
|
||||||
setstackmark(&smark);
|
setstackmark(&smark);
|
||||||
|
|
||||||
skip = 0;
|
status = 0;
|
||||||
// status = 0;
|
|
||||||
while ((n = parsecmd(0)) != NODE_EOF) {
|
while ((n = parsecmd(0)) != NODE_EOF) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = evaltree(n, 0);
|
i = evaltree(n, 0);
|
||||||
// if (n)
|
if (n)
|
||||||
// status = i;
|
status = i;
|
||||||
popstackmark(&smark);
|
popstackmark(&smark);
|
||||||
skip = evalskip;
|
if (evalskip)
|
||||||
if (skip)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
popstackmark(&smark);
|
popstackmark(&smark);
|
||||||
popfile();
|
popfile();
|
||||||
stunalloc(s);
|
stunalloc(s);
|
||||||
|
|
||||||
skip &= mask;
|
evalskip &= mask;
|
||||||
evalskip = skip;
|
return status;
|
||||||
return skip;
|
|
||||||
// return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -12272,9 +12262,9 @@ evalcmd(int argc UNUSED_PARAM, char **argv)
|
|||||||
STPUTC('\0', concat);
|
STPUTC('\0', concat);
|
||||||
p = grabstackstr(concat);
|
p = grabstackstr(concat);
|
||||||
}
|
}
|
||||||
evalstring(p, ~SKIPEVAL);
|
return evalstring(p, ~SKIPEVAL);
|
||||||
}
|
}
|
||||||
return exitstatus;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
1
shell/ash_test/ash-misc/eval1.right
Normal file
1
shell/ash_test/ash-misc/eval1.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
Ok:0
|
4
shell/ash_test/ash-misc/eval1.tests
Executable file
4
shell/ash_test/ash-misc/eval1.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
# empty eval nevertheless sets $? = 0
|
||||||
|
false
|
||||||
|
eval
|
||||||
|
echo Ok:$?
|
1
shell/hush_test/hush-misc/eval1.right
Normal file
1
shell/hush_test/hush-misc/eval1.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
Ok:0
|
4
shell/hush_test/hush-misc/eval1.tests
Executable file
4
shell/hush_test/hush-misc/eval1.tests
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
# empty eval nevertheless sets $? = 0
|
||||||
|
false
|
||||||
|
eval
|
||||||
|
echo Ok:$?
|
Loading…
Reference in New Issue
Block a user