On Monday 24 March 2008 17:45, James Simmons wrote:
> 
> This patch allows for doing [[ condition1 -a condition2 ]] 

&& doesn't work. It's always works as ||:

# ./busybox ash -c '[[ q || "" ]]; echo $?'
0
# ./busybox ash -c '[[ q && "" ]]; echo $?'
0

I changed it like this:

        for (;;) {
+               int t;
                checkkwd = savecheckkwd;
-               switch (readtoken()) {
+               t = readtoken();
+               switch (t) {
+#if ENABLE_ASH_BASH_COMPAT
+               case TAND: /* "&&" */
+               case TOR: /* "||" */
+                       if (!double_brackets_flag) {
+                               tokpushback = 1;
+                               goto out;
+                       }
+                       wordtext = (char *) (t == TAND ? "-a" : "-o");
+#endif
                case TWORD:
                        n = stzalloc(sizeof(struct narg));
                        n->type = NARG;
                        /*n->narg.next = NULL; - stzalloc did it */
                        n->narg.text = wordtext;
+#if ENABLE_ASH_BASH_COMPAT
+                       if (strcmp("[[", wordtext) == 0)
+                               double_brackets_flag = 1;
+                       else if (strcmp("]]", wordtext) == 0)
+                               double_brackets_flag = 0;
+#endif
                        n->narg.backquote = backquotelist;
                        if (savecheckkwd && isassignment(wordtext)) {
                                *vpp = n;

Thanks!
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to