From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21245 invoked from network); 23 Jun 1997 08:22:19 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 23 Jun 1997 08:22:19 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id EAA02838; Mon, 23 Jun 1997 04:06:54 -0400 (EDT) Resent-Date: Mon, 23 Jun 1997 04:06:54 -0400 (EDT) Message-Id: <199706230810.KAA02578@sgi.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list), joda@pdc.kth.se (Johan Danielsson) Subject: Re: Filename qualifier M and symbolic links In-reply-to: "Johan Danielsson"'s message of "20 Jun 1997 21:03:04 MET." Date: Mon, 23 Jun 1997 10:10:48 +0200 From: Peter Stephenson Resent-Message-ID: <"SPS4i1.0.Hi.TwYhp"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3285 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Johan Danielsson wrote: > $ ls -l > total 5 > drwxr-xr-x 2 joda 30 2048 Jun 20 20:30 a > -rw-r--r-- 1 joda 30 0 Jun 20 20:30 b > lrwxr-xr-x 1 joda 30 1 Jun 20 20:30 c -> a > $ echo *(M) > a/ b c > $ echo *(-M) > a/ b c > > Shouldn't the second echo output "a/ b c/"? Yes, I would have thought so. Try this. (It looks like this is the only stat() call that isn't somehow covered.) You get into trouble if you have list_types without following links and mark_dirs with, or vice versa, but you deserve it. It might be a little neater with bit flags instead of the gf_* variables. *** Src/glob.c.follow Mon Jun 16 10:45:58 1997 --- Src/glob.c Mon Jun 23 09:57:02 1997 *************** *** 77,83 **** /* Other state values for current pattern */ static int qualct, qualorct; static int range, amc, units; ! static int gf_nullglob, gf_markdirs, gf_noglobdots, gf_listtypes; /* Prefix, suffix for doing zle trickery */ char *glob_pre, *glob_suf; --- 77,83 ---- /* Other state values for current pattern */ static int qualct, qualorct; static int range, amc, units; ! static int gf_nullglob, gf_markdirs, gf_noglobdots, gf_listtypes, gf_follow; /* Prefix, suffix for doing zle trickery */ char *glob_pre, *glob_suf; *************** *** 172,178 **** if (gf_listtypes || gf_markdirs) { /* Add the type marker to the end of the filename */ checked = statted = 1; ! if (lstat(unmetafy(getfullpath(s), NULL), &buf)) return; if (gf_listtypes || S_ISDIR(buf.st_mode)) { char *t; --- 172,179 ---- if (gf_listtypes || gf_markdirs) { /* Add the type marker to the end of the filename */ checked = statted = 1; ! if (gf_follow ? stat(unmetafy(getfullpath(s), NULL), &buf) ! : lstat(unmetafy(getfullpath(s), NULL), &buf)) return; if (gf_listtypes || S_ISDIR(buf.st_mode)) { char *t; *************** *** 798,804 **** colonmod = NULL; gf_nullglob = isset(NULLGLOB); gf_markdirs = isset(MARKDIRS); ! gf_listtypes = 0; gf_noglobdots = unset(GLOBDOTS); if (str[sl - 1] == Outpar) { /* check for qualifiers */ char *s; --- 799,805 ---- colonmod = NULL; gf_nullglob = isset(NULLGLOB); gf_markdirs = isset(MARKDIRS); ! gf_listtypes = gf_follow = 0; gf_noglobdots = unset(GLOBDOTS); if (str[sl - 1] == Outpar) { /* check for qualifiers */ char *s; *************** *** 1052,1062 **** break; case 'M': /* Mark directories with a / */ ! gf_markdirs = !(sense & 1); break; case 'T': /* Mark types in a `ls -F' type fashion */ ! gf_listtypes = !(sense & 1); break; case 'N': /* Nullglob: remove unmatched patterns. */ --- 1053,1065 ---- break; case 'M': /* Mark directories with a / */ ! if ((gf_markdirs = !(sense & 1))) ! gf_follow = sense & 2; break; case 'T': /* Mark types in a `ls -F' type fashion */ ! if ((gf_listtypes = !(sense & 1))) ! gf_follow = sense & 2; break; case 'N': /* Nullglob: remove unmatched patterns. */ -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.