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

PATCH: recursive globs with e qualifier hangs the shell

To reproduce, you can use something like this:
  print **/*(e:print **/*:)

It hangs because addpath in glob.c is called with pathbufsz zero. It
then goes into a while loop doing pathbufsz *= 2, never exiting because
pathbufsz never increases.

It is set to zero in save_globstate which seems like a strange thing to
do. Surely it should save the actual value instead of zero. Perhaps the
original intention was to set pathbufsz instead of (N).gd_pathbufsz to
zero. The patch below appears to fix it and I can't see any problem with
it. This isn't the first time we've had problems with that glob state
saving and I suspect it won't be the last. I've also included a test.


Index: Src/glob.c
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.41
diff -u -r1.41 glob.c
--- Src/glob.c  24 Apr 2005 18:38:38 -0000      1.41
+++ Src/glob.c  8 Jun 2005 13:28:33 -0000
@@ -180,7 +180,6 @@
     memcpy(&(N), &curglobdata, sizeof(struct globdata)); \
     (N).gd_pathpos = pathpos; \
     (N).gd_pathbuf = pathbuf; \
-    (N).gd_pathbufsz = 0; \
     (N).gd_glob_pre = glob_pre; \
     (N).gd_glob_suf = glob_suf; \
     pathbuf = NULL; \
Index: Test/D02glob.ztst
RCS file: /cvsroot/zsh/zsh/Test/D02glob.ztst,v
retrieving revision 1.10
diff -u -r1.10 D02glob.ztst
--- Test/D02glob.ztst   9 May 2005 10:46:15 -0000       1.10
+++ Test/D02glob.ztst   8 Jun 2005 13:28:33 -0000
@@ -280,6 +280,10 @@
 0:Globbing used recursively (inside e glob qualifier)
 >a a b b c c
+ print glob.tmp/*/*(e:'reply=( glob.tmp/**/*([1]) )'::t)
+0:Recursive globbing used recursively (inside e glob qualifier)
+>a a a a a a a
  print glob.tmp/**/(:h) 
 0:Head modifier
 >. glob.tmp glob.tmp glob.tmp glob.tmp glob.tmp/dir3

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

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