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

PATCH: Allow using STTY= to save terminal state



A person in IRC had issues with a command (fastlane) changing some random
stty settings, which broke some stuff (prompt printed twice sometimes
etc). I suggested aliasing fastlane to "STTY=-echonl fastlane" which
causes zsh to restore stty settings after the command returns. However,
it would be nice to be able to do this without having to specify a random
stty setting to actually change when starting the command, this patch
does that.

---
 Src/exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Src/exec.c b/Src/exec.c
index 63feb6cff6..85e2f8d992 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -684,8 +684,10 @@ execute(LinkList args, int flags, int defpath)
 
     /* 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 ((s = STTYval) && isatty(0) && (GETPGRP() == getpid())) {
+     * parameter as it arguments. If the parameter is empty, we   *
+     * do nothing, but this causes the terminal settings to be    *
+     * restored later which can be useful.                        */
+    if ((s = STTYval) && *s && isatty(0) && (GETPGRP() == getpid())) {
 	char *t = tricat("stty", " ", s);
 
 	STTYval = 0;	/* this prevents infinite recursion */
-- 
2.15.1





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