1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-16 21:16:05 +02:00

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.
This commit is contained in:
Mikael Magnusson 2022-01-18 23:20:53 +01:00
parent 75c3664a62
commit 8bf0f0cf45
4 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2022-01-30 Mikael Magnusson <mikachu@gmail.com>
* 49694 + doc: Doc/Zsh/builtins.yo, Doc/Zsh/params.yo, Src/exec.c:
Allow using empty STTY= to freeze tty for a single command
2022-01-29 Daniel Shahaf <d.s@daniel.shahaf.name>
* unposted: Functions/VCS_Info/test-repo-git-rebase-apply,

View File

@ -1885,7 +1885,8 @@ unfreezing the tty does not guarantee settings made on the
command line are preserved. Strings of commands run between
editing the command line will see a consistent tty state.
See also the shell variable tt(STTY) for a means of initialising
the tty before running external commands.
the tty before running external commands and/or freezing the tty
around a single command.
)
findex(type)
item(tt(type) [ tt(-wfpamsS) ] var(name) ...)(

View File

@ -1570,6 +1570,11 @@ if it is in the environment of the shell but not explicitly assigned to in
the input line. This avoids running stty at every external command by
accidentally exporting it. Also note that tt(STTY) should not be used for
window size specifications; these will not be local to the command.
If the parameter is set and empty, all of the above applies except
that tt(stty) is not run. This can be useful as a way to freeze the tty
around a single command, blocking its changes to tty settings,
similar to the tt(ttyctl) builtin.
)
vindex(TERM)
item(tt(TERM) <S>)(

View File

@ -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 */