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

Re: extendedglob recursion (/)#



(Apologies if this ends up appearing multiple times.  Outgoing mail
from my home machine has mysteriously stopped working [I blame
Verizon] so I'm pasting the message into gmail while I figure out what
the heck is going on.)

On Feb 25,  7:51pm, Eric Cook wrote:
}
} Mikachu | % pl (/)#|wc -l
} Mikachu |  glob.c:276: BUG: statfullpath(): pathname too long
}
} What should the 'proper' behavior be? Recursing into directories below /
} or just printing `/'

Recursing into directories below / would definitely be wrong (and would
in any case need to fail with "no match" because there can only be the
one directory named "/").

There's a pretty straightforward fix:

diff --git a/Src/glob.c b/Src/glob.c
index 82f8d62..f48cb8e 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 = (p1->patmlen > 0) ? 1 + pdflag : 0;
         l1->follow = 0;
         l1->next = parsecomplist(instr);
         return (l1->pat) ? l1 : NULL;



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