about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2000-09-25 16:57:05 +0000
committerBart Schaefer <barts@users.sourceforge.net>2000-09-25 16:57:05 +0000
commit756f8186f25120bfb4c8e2ae9eaf601f329b9660 (patch)
tree99a2b7eac356406a920b081a1baaf9c4007b7788
parent4225207e4cf843a77e109c23580ca6624b56cf92 (diff)
downloadzsh-756f8186f25120bfb4c8e2ae9eaf601f329b9660.tar.gz
zsh-756f8186f25120bfb4c8e2ae9eaf601f329b9660.tar.xz
zsh-756f8186f25120bfb4c8e2ae9eaf601f329b9660.zip
Fix STTY parameter.
-rw-r--r--ChangeLog4
-rw-r--r--Src/exec.c24
2 files changed, 21 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 286946936..0d36679ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2000-09-25  Bart Schaefer  <schaefer@zsh.org>
+
+	* 12862: Src/exec.c: Fix STTY parameter to match documentation.
+
 2000-09-22  Clint Adams  <schizo@debian.org>
 
 	* 12860: Src/jobs.c: don't check length against PATH_MAX or
diff --git a/Src/exec.c b/Src/exec.c
index 8d26e604a..8ac66ede7 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -133,6 +133,7 @@ mod_export Funcstack funcstack;
 
 static LinkList args;
 static int doneps4;
+static char *STTYval;
 
 /* Execution functions. */
 
@@ -444,7 +445,6 @@ void
 execute(Cmdnam not_used_yet, int dash)
 {
     Cmdnam cn;
-    static LinkList exargs;
     char buf[MAXCMDLEN], buf2[MAXCMDLEN];
     char *s, *z, *arg0;
     char **argv, **pp;
@@ -459,17 +459,19 @@ execute(Cmdnam not_used_yet, int dash)
     /* If the parameter STTY is set in the command's environment, *
      * we first run the stty command with the value of this       *
      * parameter as it arguments.                                 */
-    if (!exargs && (s = zgetenv("STTY")) && isatty(0) &&
-	(GETPGRP() == getpid())) {
-	char *t;
+    if ((s = STTYval) && isatty(0) && (GETPGRP() == getpid())) {
+	LinkList exargs = args;
+	char *t = tricat("stty", " ", s);
 
-	exargs = args;	/* this prevents infinite recursion */
+	STTYval = 0;	/* this prevents infinite recursion */
+	zsfree(s);
 	args = NULL;
-	t = tricat("stty", " ", s);
 	execstring(t, 1, 0);
 	zsfree(t);
 	args = exargs;
-	exargs = NULL;
+    } else if (s) {
+	STTYval = 0;
+	zsfree(s);
     }
 
     cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0);
@@ -1537,6 +1539,10 @@ addvars(Estate state, Wordcode pc, int export)
 		    state->pc = opc;
 		    return;
 		}
+		if (strcmp(name, "STTY") == 0) {
+		    zsfree(STTYval);
+		    STTYval = ztrdup(val);
+		}
 		allexp = opts[ALLEXPORT];
 		opts[ALLEXPORT] = 1;
 		pm = setsparam(name, val);
@@ -2326,6 +2332,10 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		if (!forked)
 		    setlimits(NULL);
 #endif
+		if (how & Z_ASYNC) {
+		    zsfree(STTYval);
+		    STTYval = 0;
+		}
 		execute((Cmdnam) hn, cflags & BINF_DASH);
 	    } else {		/* ( ... ) */
 		DPUTS(varspc,