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

PATCH: %_ in $PS4



This sometimes showed a wrong string because we didn't clear/restore
cmdstack in source().

And things like $(...) didn't show anything special for `%_'.

Bye
 Sven

diff -ru ../z.old/Src/exec.c Src/exec.c
--- ../z.old/Src/exec.c	Wed Mar 22 14:22:53 2000
+++ Src/exec.c	Wed Mar 22 14:57:14 2000
@@ -2672,7 +2672,9 @@
     redup(pipes[1], 1);
     opts[MONITOR] = 0;
     entersubsh(Z_SYNC, 1, 0);
+    cmdpush(CS_CMDSUBST);
     execode(prog, 0, 1);
+    cmdpop();
     close(1);
     _exit(lastval);
     zerr("exit returned in child!!", NULL, 0);
@@ -2801,7 +2803,9 @@
     redup(fd, 1);
     opts[MONITOR] = 0;
     entersubsh(Z_SYNC, 1, 0);
+    cmdpush(CS_CMDSUBST);
     execode(prog, 0, 1);
+    cmdpop();
     close(1);
     _exit(lastval);
     zerr("exit returned in child!!", NULL, 0);
@@ -2885,7 +2889,9 @@
     redup(pipes[out], out);
     closem(0);   /* this closes pipes[!out] as well */
 #endif
+    cmdpush(CS_CMDSUBST);
     execode(prog, 0, 1);
+    cmdpop();
     zclose(out);
     _exit(lastval);
     return NULL;
@@ -2911,7 +2917,9 @@
     entersubsh(Z_ASYNC, 1, 0);
     redup(pipes[out], out);
     closem(0);	/* this closes pipes[!out] as well */
+    cmdpush(CS_CMDSUBST);
     execode(prog, 0, 1);
+    cmdpop();
     _exit(lastval);
     return 0;
 }
@@ -2963,7 +2971,9 @@
 	fprintf(xtrerr, "[[");
 	tracingcond++;
     }
+    cmdpush(CS_COND);
     stat = !evalcond(state);
+    cmdpop();
     if (isset(XTRACE)) {
 	fprintf(xtrerr, " ]]\n");
 	fflush(xtrerr);
@@ -2986,6 +2996,7 @@
 	printprompt4();
 	fprintf(xtrerr, "((");
     }
+    cmdpush(CS_MATH);
     e = ecgetstr(state, EC_DUPTOK, &htok);
     if (htok)
 	singsub(&e);
@@ -2993,6 +3004,8 @@
 	fprintf(xtrerr, " %s", e);
 
     val = mathevali(e);
+
+    cmdpop();
 
     if (isset(XTRACE)) {
 	fprintf(xtrerr, " ))\n");
diff -ru ../z.old/Src/init.c Src/init.c
--- ../z.old/Src/init.c	Wed Mar 22 14:22:53 2000
+++ Src/init.c	Wed Mar 22 14:47:19 2000
@@ -900,6 +900,8 @@
     int oldshst, osubsh, oloops;
     FILE *obshin;
     char *old_scriptname = scriptname, *us;
+    char *ocs;
+    int ocsp;
 
     if (!s || 
 	(!(prog = try_source_file((us = unmeta(s)))) &&
@@ -915,6 +917,10 @@
     oldlineno = lineno;          /* store our current lineno                  */
     oloops    = loops;           /* stored the # of nested loops we are in    */
     oldshst   = opts[SHINSTDIN]; /* store current value of this option        */
+    ocs = cmdstack;
+    ocsp = cmdsp;
+    cmdstack = (unsigned char *) zalloc(CMDSTACKSZ);
+    cmdsp = 0;
 
     if (!prog) {
 	SHIN = tempfd;
@@ -953,6 +959,9 @@
     errflag = 0;
     retflag = 0;
     scriptname = old_scriptname;
+    free(cmdstack);
+    cmdstack = ocs;
+    cmdsp = ocsp;
 
     return 0;
 }

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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