about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2022-01-18 23:20:53 +0100
committerMikael Magnusson <mikachu@gmail.com>2022-01-30 18:14:54 +0100
commit8bf0f0cf45606971d1433b36ce21ab45f6226004 (patch)
treedaac95b637e6c878f0185dd25d029ca4649993ad /Src
parent75c3664a62010dfae620d77930f8ea5aae78b602 (diff)
downloadzsh-8bf0f0cf45606971d1433b36ce21ab45f6226004.tar.gz
zsh-8bf0f0cf45606971d1433b36ce21ab45f6226004.tar.xz
zsh-8bf0f0cf45606971d1433b36ce21ab45f6226004.zip
49694 + doc: Allow using empty STTY= to freeze tty for a single command
Previously, doing this would just run stty with no arguments, which
normally causes it to print some terminal settings to stdout.
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 1860a10ed..f67074846 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 */