From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27778 invoked from network); 12 Nov 1998 14:28:56 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Nov 1998 14:28:56 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id JAA02076; Thu, 12 Nov 1998 09:25:50 -0500 (EST) Resent-Date: Thu, 12 Nov 1998 09:25:50 -0500 (EST) Message-Id: <9811121410.AA34177@ibmth.df.unipi.it> To: Zsh Hackers Subject: Re: PATCH: 3.1.5: ``***'' symlink follow broken In-Reply-To: "Geoff Wing"'s message of "Thu, 12 Nov 1998 17:20:55 NFT." <19981112172055.A21356@primenet.com.au> Date: Thu, 12 Nov 1998 15:10:36 +0100 From: Peter Stephenson Resent-Message-ID: <"xVvDo2.0.JW.k_kIs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4614 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Geoff Wing wrote: > Heyla, > ``***'' recursive globbing with symlink follow has been broken since at > least 3.1.2 (maybe before): It's amazing how the shell can totally break down without anyone noticing. > This patch is probably suboptimal (possibly wrong) and may encourage someone > to make a real patch. 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. 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()? *** Src/glob.c.follow Sun Nov 8 16:01:28 1998 --- Src/glob.c Thu Nov 12 14:59:26 1998 *************** *** 365,372 **** if (dirs) { struct stat st; stat(fn, &st); ! /* a directory with subdirectories has link count greater than 2 */ ! if (!S_ISDIR(st.st_mode) || st.st_nlink == 2) return; } lock = opendir(fn); --- 365,374 ---- if (dirs) { struct stat st; stat(fn, &st); ! /* a directory with subdirectories has link count greater than 2 ! * (unless the `subdirectory' is a symbolic link). ! */ ! if (!S_ISDIR(st.st_mode) || (st.st_nlink == 2 && !q->follow)) return; } lock = opendir(fn); -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56100 Pisa, Italy