From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29080 invoked from network); 12 Nov 1998 17:28:22 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Nov 1998 17:28:22 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id MAA09185; Thu, 12 Nov 1998 12:23:51 -0500 (EST) Resent-Date: Thu, 12 Nov 1998 12:23:51 -0500 (EST) From: "Bart Schaefer" Message-Id: <981112092146.ZM11912@candle.brasslantern.com> Date: Thu, 12 Nov 1998 09:21:46 -0800 In-Reply-To: <9811121410.AA34177@ibmth.df.unipi.it> Comments: In reply to Peter Stephenson "Re: PATCH: 3.1.5: ``***'' symlink follow broken" (Nov 12, 3:10pm) References: <9811121410.AA34177@ibmth.df.unipi.it> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Zsh Hackers Subject: Re: PATCH: 3.1.5: ``***'' symlink follow broken MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"ENfrW1.0.SF2.dcnIs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4617 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Nov 12, 3:10pm, Peter Stephenson wrote: } Subject: Re: PATCH: 3.1.5: ``***'' symlink follow broken } } Geoff Wing wrote: } > ``***'' recursive globbing with symlink follow has been broken } } It's amazing how the shell can totally break down without anyone } noticing. I must sheepishly admit that I only really use 3.1.x when I'm playing with it or changing its code. The machine I use most of the day at work has 3.0.5-extended installed. } > This patch is probably suboptimal (possibly wrong) } } It works fine, but there's one minor tweak: you can still reject } things that aren't directories (the test correctly uses stat(), not } lstat(), so it may be a link to a directory), but the link count test } doesn't apply when the directory could contain only symbolic links. Yes, that's exactly the problem ... but ... } The following patch is a replacement which does that. I can't imagine } the difference is that important -- in fact, since the opendir() will } fail if the thing isn't a directory, it's hard to see that the stat() } at this point gains much at all. Unless someone knows something } sinister about opendir()? I *think* what's going on here is that `dirs' means the *next* level of comparison needs to match directories inside which the final files may reside. The stat() is intended to short-circuit the search when there are no such subdirectories, before iterating through the entries in the `while (zreaddir())' loop that follows. It's only a bonus that it also avoids calling opendir() on a non-directory, and it's useless if the link count test is invalid. So *unless* somebody knows of a reason not to do opendir() on something that isn't a directory, I think Geoff's patch is actually better [on the assumption that a failed opendir() is faster than a successful stat()]. Late last night I was of the opinion that `closure' mattered more than did `q->follow', but I've since revised that opinion. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com