zsh-workers
 help / color / mirror / code / Atom feed
* [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+]
@ 2003-03-18  3:16 Clint Adams
  2003-03-18 16:25 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2003-03-18  3:16 UTC (permalink / raw)
  To: zsh-workers; +Cc: 185228-forwarded

----- Forwarded message from Vincent Lefevre <vincent@vinc17.org> -----

Using the glob qualifier mh+n selects files modified more than
n+1 hours instead of more than n hours ago. For instance:

ay:~/zshtst> ls -lgot *                                                <2:47:04
-rw-r--r--    1    52954 2003-03-18 02:30 tst-1047861059-68-2-batch.results
-rw-r--r--    1    57580 2003-03-18 02:29 tst-1047861059-37-2-batch.results
-rw-r--r--    1   147253 2003-03-18 02:26 tst-1047861059-38-2-batch.results
-rw-r--r--    1      121 2003-03-18 02:26 tst-1047861059-38-3-batch.results
-rw-r--r--    1   149771 2003-03-18 00:54 tst-1047861059-68-1-batch.results
-rw-r--r--    1   152224 2003-03-18 00:51 tst-1047861059-67-4-batch.results
-rw-r--r--    1   148653 2003-03-17 23:23 tst-1047861059-67-3-batch.results
-rw-r--r--    1   147979 2003-03-17 22:01 tst-1047861059-67-2-batch.results
-rw-r--r--    1   147419 2003-03-17 22:01 tst-1047861059-37-1-batch.results
-rw-r--r--    1   148014 2003-03-17 20:44 tst-1047861059-67-1-batch.results
-rw-r--r--    1   144904 2003-03-17 19:13 tst-1047861059-18-4-batch.results
-rw-r--r--    1   149671 2003-03-17 18:39 tst-1047861059-17-4-batch.results
-rw-r--r--    1   149066 2003-03-17 18:32 tst-1047861059-38-1-batch.results
ay:~/zshtst> ls -lgot *(mh+0)                                          <2:47:10
-rw-r--r--    1   149771 2003-03-18 00:54 tst-1047861059-68-1-batch.results
-rw-r--r--    1   152224 2003-03-18 00:51 tst-1047861059-67-4-batch.results
-rw-r--r--    1   148653 2003-03-17 23:23 tst-1047861059-67-3-batch.results
-rw-r--r--    1   147979 2003-03-17 22:01 tst-1047861059-67-2-batch.results
-rw-r--r--    1   147419 2003-03-17 22:01 tst-1047861059-37-1-batch.results
-rw-r--r--    1   148014 2003-03-17 20:44 tst-1047861059-67-1-batch.results
-rw-r--r--    1   144904 2003-03-17 19:13 tst-1047861059-18-4-batch.results
-rw-r--r--    1   149671 2003-03-17 18:39 tst-1047861059-17-4-batch.results
-rw-r--r--    1   149066 2003-03-17 18:32 tst-1047861059-38-1-batch.results
ay:~/zshtst> ls -lgot *(mh+1)                                          <2:47:12
-rw-r--r--    1   148653 2003-03-17 23:23 tst-1047861059-67-3-batch.results
-rw-r--r--    1   147979 2003-03-17 22:01 tst-1047861059-67-2-batch.results
-rw-r--r--    1   147419 2003-03-17 22:01 tst-1047861059-37-1-batch.results
-rw-r--r--    1   148014 2003-03-17 20:44 tst-1047861059-67-1-batch.results
-rw-r--r--    1   144904 2003-03-17 19:13 tst-1047861059-18-4-batch.results
-rw-r--r--    1   149671 2003-03-17 18:39 tst-1047861059-17-4-batch.results
-rw-r--r--    1   149066 2003-03-17 18:32 tst-1047861059-38-1-batch.results
ay:~/zshtst> ls -lgot *(mh+2)                                          <2:47:13
-rw-r--r--    1   148653 2003-03-17 23:23 tst-1047861059-67-3-batch.results
-rw-r--r--    1   147979 2003-03-17 22:01 tst-1047861059-67-2-batch.results
-rw-r--r--    1   147419 2003-03-17 22:01 tst-1047861059-37-1-batch.results
-rw-r--r--    1   148014 2003-03-17 20:44 tst-1047861059-67-1-batch.results
-rw-r--r--    1   144904 2003-03-17 19:13 tst-1047861059-18-4-batch.results
-rw-r--r--    1   149671 2003-03-17 18:39 tst-1047861059-17-4-batch.results
-rw-r--r--    1   149066 2003-03-17 18:32 tst-1047861059-38-1-batch.results
ay:~/zshtst> ls -lgot *(mh+3)                                          <2:47:15
-rw-r--r--    1   147979 2003-03-17 22:01 tst-1047861059-67-2-batch.results
-rw-r--r--    1   147419 2003-03-17 22:01 tst-1047861059-37-1-batch.results
-rw-r--r--    1   148014 2003-03-17 20:44 tst-1047861059-67-1-batch.results
-rw-r--r--    1   144904 2003-03-17 19:13 tst-1047861059-18-4-batch.results
-rw-r--r--    1   149671 2003-03-17 18:39 tst-1047861059-17-4-batch.results
-rw-r--r--    1   149066 2003-03-17 18:32 tst-1047861059-38-1-batch.results
ay:~/zshtst> ls -lgot *(mh+4)                                          <2:47:16
-rw-r--r--    1   148014 2003-03-17 20:44 tst-1047861059-67-1-batch.results
-rw-r--r--    1   144904 2003-03-17 19:13 tst-1047861059-18-4-batch.results
-rw-r--r--    1   149671 2003-03-17 18:39 tst-1047861059-17-4-batch.results
-rw-r--r--    1   149066 2003-03-17 18:32 tst-1047861059-38-1-batch.results
ay:~/zshtst> ls -lgot *(mh+5)                                          <2:47:18
-rw-r--r--    1   148014 2003-03-17 20:44 tst-1047861059-67-1-batch.results
-rw-r--r--    1   144904 2003-03-17 19:13 tst-1047861059-18-4-batch.results
-rw-r--r--    1   149671 2003-03-17 18:39 tst-1047861059-17-4-batch.results
-rw-r--r--    1   149066 2003-03-17 18:32 tst-1047861059-38-1-batch.results

If this is a feature to make a partition with mh-n, mhn and mh+n,
then the wording in the manual should be changed to make things
clear. But IMHO, this would be inintuitive.


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

* Re: [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+]
  2003-03-18  3:16 [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+] Clint Adams
@ 2003-03-18 16:25 ` Bart Schaefer
  2005-07-11 12:17   ` Vincent Lefevre
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2003-03-18 16:25 UTC (permalink / raw)
  To: zsh-workers; +Cc: 185228-forwarded

On Mar 17, 10:16pm, Clint Adams wrote:
} Subject: [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generati
}
} ----- Forwarded message from Vincent Lefevre <vincent@vinc17.org> -----
} 
} Using the glob qualifier mh+n selects files modified more than
} n+1 hours instead of more than n hours ago.
} 
} If this is a feature to make a partition with mh-n, mhn and mh+n,
} then the wording in the manual should be changed

Unless I'm mistaken, this is all for compatibility with the way that
"find" defines +n, -n and n.  If you ask me, it's always silly to
define any meaning for "exactly <number> <timeunits> ago"; it always
means "during the <timeunit> that began <number> <timeunits> before
the current <timeunit> began" (but then for any significantly large
unit you can get into arguments about what "began" means).  But zsh
did not invent the nomenclature.


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

* Re: [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+]
  2003-03-18 16:25 ` Bart Schaefer
@ 2005-07-11 12:17   ` Vincent Lefevre
  2007-12-13 18:25     ` Clint Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Vincent Lefevre @ 2005-07-11 12:17 UTC (permalink / raw)
  To: zsh-workers, 185228-forwarded

On 2003-03-18 16:25:10 +0000, Bart Schaefer wrote:
> On Mar 17, 10:16pm, Clint Adams wrote:
> } Subject: [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generati
> }
> } ----- Forwarded message from Vincent Lefevre <vincent@vinc17.org> -----
> } 
> } Using the glob qualifier mh+n selects files modified more than
> } n+1 hours instead of more than n hours ago.
> } 
> } If this is a feature to make a partition with mh-n, mhn and mh+n,
> } then the wording in the manual should be changed
> 
> Unless I'm mistaken, this is all for compatibility with the way that
> "find" defines +n, -n and n.  If you ask me, it's always silly to
> define any meaning for "exactly <number> <timeunits> ago"; it always
> means "during the <timeunit> that began <number> <timeunits> before
> the current <timeunit> began" (but then for any significantly large
> unit you can get into arguments about what "began" means).  But zsh
> did not invent the nomenclature.

BTW, could zsh define <n and >n, that would have the intuitive
meaning? e.g. echo *(ah>5) would display the files accessed more
that 5 hours (= 18000 seconds) ago.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+]
  2005-07-11 12:17   ` Vincent Lefevre
@ 2007-12-13 18:25     ` Clint Adams
  2007-12-13 22:35       ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2007-12-13 18:25 UTC (permalink / raw)
  To: Vincent Lefevre, zsh-workers, 185228

On Mon, Jul 11, 2005 at 02:17:00PM +0200, Vincent Lefevre wrote:
> BTW, could zsh define <n and >n, that would have the intuitive
> meaning? e.g. echo *(ah>5) would display the files accessed more
> that 5 hours (= 18000 seconds) ago.

Sounds unlikely.


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

* Re: [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+]
  2007-12-13 18:25     ` Clint Adams
@ 2007-12-13 22:35       ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2007-12-13 22:35 UTC (permalink / raw)
  To: zsh-workers, 185228

On Thu, 13 Dec 2007 13:25:03 -0500
Clint Adams <schizo@debian.org> wrote:
> On Mon, Jul 11, 2005 at 02:17:00PM +0200, Vincent Lefevre wrote:
> > BTW, could zsh define <n and >n, that would have the intuitive
> > meaning? e.g. echo *(ah>5) would display the files accessed more
> > that 5 hours (= 18000 seconds) ago.
> 
> Sounds unlikely.

It turns out not to be too difficult, although I had to make < and > in
parentheses no longer be parse errors.  There's no good reason why they
should be parse errors there that I can see and we already do similar
things in lots of other cases.

I'll let everyone worry about this overnight while I finally get some
rest.

Index: Doc/Zsh/expn.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v
retrieving revision 1.85
diff -u -r1.85 expn.yo
--- Doc/Zsh/expn.yo	13 Dec 2007 21:57:18 -0000	1.85
+++ Doc/Zsh/expn.yo	13 Dec 2007 22:33:48 -0000
@@ -2069,7 +2069,7 @@
 item(tt(g)var(id))(
 like tt(u)var(id) but with group IDs or names
 )
-item(tt(a)[tt(Mwhms)][tt(-)|tt(PLUS())]var(n))(
+item(tt(a)[tt(Mwhms)][tt(-)|tt(PLUS())|tt(<)|tt(>)]var(n))(
 files accessed exactly var(n) days ago.  Files accessed within the last
 var(n) days are selected using a negative value for var(n) (tt(-)var(n)).
 Files accessed more than var(n) days ago are selected by a positive var(n)
@@ -2079,11 +2079,18 @@
 instead of days, respectively.
 
 Any fractional part of the difference between the access time and the
-current part in the appropriate units is ignored in the comparison.  For
+current time in the appropriate units is ignored in the comparison.  For
 instance, `tt(echo *(ah-5))' would echo files accessed within the last
 five hours, while `tt(echo *(ah+5))' would echo files accessed at least
-six hours ago, as times strictly between five and six hours are treated
-as five hours.
+six hours ago, as times between five and six hours are treated as five
+hours.
+
+To perform comparisons strictly rather than using the truncated value,
+tt(<) and tt(>) may be used in place of tt(-) and tt(PLUS()).  The test
+with tt(<) is true if the time difference is less than the given period;
+this is equivalent to tt(-) because of the manner of truncation.  The
+test with tt(>) is true if the time difference is strictly greater than
+the period specified.
 )
 item(tt(m)[tt(Mwhms)][tt(-)|tt(PLUS())]var(n))(
 like the file access qualifier, except that it uses the file modification
Index: Src/glob.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.61
diff -u -r1.61 glob.c
--- Src/glob.c	1 Nov 2007 17:57:57 -0000	1.61
+++ Src/glob.c	13 Dec 2007 22:33:50 -0000
@@ -1440,7 +1440,32 @@
 			    g_units = TT_SECONDS, ++s;
 		    }
 		    /* See if it's greater than, equal to, or less than */
-		    if ((g_range = *s == '+' ? 1 : *s == '-' ? -1 : 0))
+		    switch (*s) {
+			/* integer greater than */
+		    case '+':
+			g_range = 1;
+			break;
+
+		    case '>':
+		    case OUTPAR:
+			/* strictly greater than */
+			g_range = 2;
+			break;
+
+		    case '-':
+		    case '<':
+		    case INANG:
+			/* integer less than, same as strictly less than */
+			g_range = -1;
+			break;
+
+		    default:
+			/* integer match */
+			g_range = 0;
+			break;
+		    }
+			   
+		    if (g_range)
 			++s;
 		    data = qgetnum(&s);
 		    break;
@@ -3236,7 +3261,7 @@
 static int
 qualtime(UNUSED(char *name), struct stat *buf, off_t days, UNUSED(char *dummy))
 {
-    time_t now, diff;
+    time_t now, diff, div, units;
 
     time(&now);
     diff = now - (g_amc == 0 ? buf->st_atime : g_amc == 1 ? buf->st_mtime :
@@ -3244,25 +3269,33 @@
     /* handle multipliers indicating units */
     switch (g_units) {
     case TT_DAYS:
-	diff /= 86400l;
+	units = 86400l;
 	break;
     case TT_HOURS:
-	diff /= 3600l;
+	units = 3600l;
 	break;
     case TT_MINS:
-	diff /= 60l;
+	units = 60l;
 	break;
     case TT_WEEKS:
-	diff /= 604800l;
+	units = 604800l;
 	break;
     case TT_MONTHS:
-	diff /= 2592000l;
+	units = 2592000l;
+	break;
+    default:
+	units = 1l;
 	break;
     }
 
-    return (g_range < 0 ? diff < days :
-	    g_range > 0 ? diff > days :
-	    diff == days);
+    div = diff / units;
+    if (g_range == 2) {
+	/* strictly greater than */
+	return div > days || (div == days && diff > div * units);
+    }
+    return (g_range < 0 ? div < days :
+	    g_range > 0 ? div > days :
+	    div == days);
 }
 
 /* evaluate a string */
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.41
diff -u -r1.41 lex.c
--- Src/lex.c	23 Aug 2007 22:04:25 -0000	1.41
+++ Src/lex.c	13 Dec 2007 22:33:51 -0000
@@ -1099,7 +1099,7 @@
 	    break;
 	case LX2_OUTANG:
 	    if (!intpos) {
-		if (in_brace_param || sub)
+		if (in_brace_param || pct || sub)
 		    break;
 		else
 		    goto brk;


-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

end of thread, other threads:[~2007-12-13 22:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-18  3:16 [vincent@vinc17.org: Bug#185228: zsh: Incorrect filename generation with glob qualifier mh+] Clint Adams
2003-03-18 16:25 ` Bart Schaefer
2005-07-11 12:17   ` Vincent Lefevre
2007-12-13 18:25     ` Clint Adams
2007-12-13 22:35       ` 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).