zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Allow using STTY= to save terminal state
Date: Tue, 18 Jan 2022 23:24:14 +0100	[thread overview]
Message-ID: <20220118222414.2507-1-mikachu@gmail.com> (raw)

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



             reply	other threads:[~2022-01-18 22:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 22:24 Mikael Magnusson [this message]
2022-01-18 22:27 ` Bart Schaefer
2022-01-18 23:17   ` Mikael Magnusson
2022-01-19  1:10     ` Bart Schaefer
2022-01-19 14:06     ` Daniel Shahaf
2022-01-19 17:29       ` Bart Schaefer
2022-01-19 20:08         ` Peter Stephenson
2022-01-21  7:11           ` Daniel Shahaf
2022-01-22 22:44             ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220118222414.2507-1-mikachu@gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).