Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: time time



[ sunsite sleeping again, great ]

Just found this on the Debian bug list...

Doing `time time' can be deadly. The problem is that it can't handle
time-in-a-time, but it still takes the second `time' as a special
token.

Dunno if this fix is correct, it makes the second `time' be taken as a 
command name. At least it fixes the bug and trying to measure the
execution time of `time' without a command doesn't make sense
anyway. We could also make it report an error (bash does that, ksh
reports the times of `time' without arguments (hm) and the DU sh does
what zsh does with this patch -- measure execution times of the
external command `time').

Bye
 Sven

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.8
diff -u -r1.8 parse.c
--- Src/parse.c	2000/05/27 08:32:58	1.8
+++ Src/parse.c	2000/06/14 09:23:30
@@ -799,10 +799,6 @@
 	par_funcdef();
 	cmdpop();
 	break;
-    case TIME:
-	*complex = 1;
-	par_time();
-	break;
     case DINBRACK:
 	cmdpush(CS_COND);
 	par_dinbrack();
@@ -813,6 +809,20 @@
 	ecstr(tokstr);
 	yylex();
 	break;
+    case TIME:
+	{
+	    static int inpartime = 0;
+
+	    if (!inpartime) {
+		*complex = 1;
+		inpartime = 1;
+		par_time();
+		inpartime = 0;
+		break;
+	    }
+	}
+	tok = STRING;
+	/* fall through */
     default:
 	{
 	    int sr;

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author