zsh-workers
 help / color / mirror / code / Atom feed
* Filename qualifier M and symbolic links
@ 1997-06-20 19:03 Johan Danielsson
  1997-06-23  8:10 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Danielsson @ 1997-06-20 19:03 UTC (permalink / raw)
  To: zsh-workers


$ echo $ZSH_VERSION
3.1.2
$ 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/"?

/Johan


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Filename qualifier M and symbolic links
  1997-06-20 19:03 Filename qualifier M and symbolic links Johan Danielsson
@ 1997-06-23  8:10 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1997-06-23  8:10 UTC (permalink / raw)
  To: Zsh hackers list, Johan Danielsson

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-06-23  8:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-20 19:03 Filename qualifier M and symbolic links Johan Danielsson
1997-06-23  8:10 ` Peter Stephenson

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).