Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Filename qualifier M and symbolic links
- X-seq: zsh-workers 3285
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list), joda@xxxxxxxxxx (Johan Danielsson)
- Subject: Re: Filename qualifier M and symbolic links
- Date: Mon, 23 Jun 1997 10:10:48 +0200
- In-reply-to: "Johan Danielsson"'s message of "20 Jun 1997 21:03:04 MET." <xofhgetjdw7.fsf@xxxxxxxxxxxxxxxx>
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 <pws@xxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author