Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: extendedglob recursion (/)#



On Feb 25,  8:56pm, Bart Schaefer wrote:
}
} +        /* special case (/)# to avoid infinite recursion */
} +        l1->closure = (p1->patmlen > 0) ? 1 + pdflag : 0;

Sorry, that's not correct.  patmlen can be zero in cases other than (/).

diff --git a/Src/glob.c b/Src/glob.c
index 82f8d62..33facde 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -708,7 +708,8 @@ parsecomplist(char *instr)
 	    }
 	    l1 = (Complist) zhalloc(sizeof *l1);
 	    l1->pat = p1;
-	    l1->closure = 1 + pdflag;
+	    /* special case (/)# to avoid infinite recursion */
+	    l1->closure = (*((char *)p1 + p1->startoff)) ? 1 + pdflag : 0;
 	    l1->follow = 0;
 	    l1->next = parsecomplist(instr);
 	    return (l1->pat) ? l1 : NULL;



Messages sorted by: Reverse Date, Date, Thread, Author