aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-25 07:49:43 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-25 07:49:43 +0000
commit80591b0a000e88c284bd2ec355f27e19e1da7528 (patch)
tree101b48a0a2c5506e6c818717c8ef7d66b857d6a7 /shell/ash.c
parentb02cea12129f1aa484701317f38466ec9e1c8462 (diff)
downloadbusybox-w32-80591b0a000e88c284bd2ec355f27e19e1da7528.tar.gz
busybox-w32-80591b0a000e88c284bd2ec355f27e19e1da7528.tar.bz2
busybox-w32-80591b0a000e88c284bd2ec355f27e19e1da7528.zip
ash: support for && and || in [[ expr ]]; add testsuite checks
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 9024d783d..3651929c2 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8470,8 +8470,10 @@ static const struct builtincmd builtintab[] = {
8470 { BUILTIN_SPEC_REG ":", truecmd }, 8470 { BUILTIN_SPEC_REG ":", truecmd },
8471#if ENABLE_ASH_BUILTIN_TEST 8471#if ENABLE_ASH_BUILTIN_TEST
8472 { BUILTIN_REGULAR "[", testcmd }, 8472 { BUILTIN_REGULAR "[", testcmd },
8473#if ENABLE_ASH_BASH_COMPAT
8473 { BUILTIN_REGULAR "[[", testcmd }, 8474 { BUILTIN_REGULAR "[[", testcmd },
8474#endif 8475#endif
8476#endif
8475#if ENABLE_ASH_ALIAS 8477#if ENABLE_ASH_ALIAS
8476 { BUILTIN_REG_ASSG "alias", aliascmd }, 8478 { BUILTIN_REG_ASSG "alias", aliascmd },
8477#endif 8479#endif
@@ -8534,17 +8536,25 @@ static const struct builtincmd builtintab[] = {
8534 { BUILTIN_REGULAR "wait", waitcmd }, 8536 { BUILTIN_REGULAR "wait", waitcmd },
8535}; 8537};
8536 8538
8537 8539/* Should match the above table! */
8538#define COMMANDCMD (builtintab + 5 + \ 8540#define COMMANDCMD (builtintab + \
8539 2 * ENABLE_ASH_BUILTIN_TEST + \ 8541 2 + \
8540 ENABLE_ASH_ALIAS + \ 8542 1 * ENABLE_ASH_BUILTIN_TEST + \
8541 ENABLE_ASH_JOB_CONTROL) 8543 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
8542#define EXECCMD (builtintab + 7 + \ 8544 1 * ENABLE_ASH_ALIAS + \
8543 2 * ENABLE_ASH_BUILTIN_TEST + \ 8545 1 * ENABLE_ASH_JOB_CONTROL + \
8544 ENABLE_ASH_ALIAS + \ 8546 3)
8545 ENABLE_ASH_JOB_CONTROL + \ 8547#define EXECCMD (builtintab + \
8546 ENABLE_ASH_CMDCMD + \ 8548 2 + \
8547 ENABLE_ASH_BUILTIN_ECHO) 8549 1 * ENABLE_ASH_BUILTIN_TEST + \
8550 1 * ENABLE_ASH_BUILTIN_TEST * ENABLE_ASH_BASH_COMPAT + \
8551 1 * ENABLE_ASH_ALIAS + \
8552 1 * ENABLE_ASH_JOB_CONTROL + \
8553 3 + \
8554 1 * ENABLE_ASH_CMDCMD + \
8555 1 + \
8556 ENABLE_ASH_BUILTIN_ECHO + \
8557 1)
8548 8558
8549/* 8559/*
8550 * Search the table of builtin commands. 8560 * Search the table of builtin commands.
@@ -10048,6 +10058,9 @@ simplecmd(void)
10048 union node *vars, **vpp; 10058 union node *vars, **vpp;
10049 union node **rpp, *redir; 10059 union node **rpp, *redir;
10050 int savecheckkwd; 10060 int savecheckkwd;
10061#if ENABLE_ASH_BASH_COMPAT
10062 smallint double_brackets_flag = 0;
10063#endif
10051 10064
10052 args = NULL; 10065 args = NULL;
10053 app = &args; 10066 app = &args;
@@ -10058,13 +10071,30 @@ simplecmd(void)
10058 10071
10059 savecheckkwd = CHKALIAS; 10072 savecheckkwd = CHKALIAS;
10060 for (;;) { 10073 for (;;) {
10074 int t;
10061 checkkwd = savecheckkwd; 10075 checkkwd = savecheckkwd;
10062 switch (readtoken()) { 10076 t = readtoken();
10077 switch (t) {
10078#if ENABLE_ASH_BASH_COMPAT
10079 case TAND: /* "&&" */
10080 case TOR: /* "||" */
10081 if (!double_brackets_flag) {
10082 tokpushback = 1;
10083 goto out;
10084 }
10085 wordtext = (char *) (t == TAND ? "-a" : "-o");
10086#endif
10063 case TWORD: 10087 case TWORD:
10064 n = stzalloc(sizeof(struct narg)); 10088 n = stzalloc(sizeof(struct narg));
10065 n->type = NARG; 10089 n->type = NARG;
10066 /*n->narg.next = NULL; - stzalloc did it */ 10090 /*n->narg.next = NULL; - stzalloc did it */
10067 n->narg.text = wordtext; 10091 n->narg.text = wordtext;
10092#if ENABLE_ASH_BASH_COMPAT
10093 if (strcmp("[[", wordtext) == 0)
10094 double_brackets_flag = 1;
10095 else if (strcmp("]]", wordtext) == 0)
10096 double_brackets_flag = 0;
10097#endif
10068 n->narg.backquote = backquotelist; 10098 n->narg.backquote = backquotelist;
10069 if (savecheckkwd && isassignment(wordtext)) { 10099 if (savecheckkwd && isassignment(wordtext)) {
10070 *vpp = n; 10100 *vpp = n;