zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@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
Date: Mon, 23 Jun 1997 10:10:48 +0200	[thread overview]
Message-ID: <199706230810.KAA02578@sgi.ifh.de> (raw)
In-Reply-To: "Johan Danielsson"'s message of "20 Jun 1997 21:03:04 MET." <xofhgetjdw7.fsf@blubb.pdc.kth.se>

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@ifh.de>       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.


      reply	other threads:[~1997-06-23  8:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-20 19:03 Johan Danielsson
1997-06-23  8:10 ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199706230810.KAA02578@sgi.ifh.de \
    --to=pws@ifh.de \
    --cc=joda@pdc.kth.se \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).