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

41275: Leave stdin open when executing widgets

This commit is contained in:
Stephane Chazelas 2017-06-13 21:34:55 -04:00 committed by Eric Cook
parent eb783754bd
commit 4d007e269d
5 changed files with 28 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2017-06-13 Eric Cook <llua@gmx.com>
* Stephane: 41275: Src/Zle/zle_main.c: Leave stdin open
when executing widgets.
2017-06-13 Peter Stephenson <p.stephenson@samsung.com> 2017-06-13 Peter Stephenson <p.stephenson@samsung.com>
* 41284: Src/builtin.c, Test/B01cd.ztst: fix null dereference on * 41284: Src/builtin.c, Test/B01cd.ztst: fix null dereference on

View File

@ -750,12 +750,12 @@ sect(User-Defined Widgets)
cindex(widgets, user-defined) cindex(widgets, user-defined)
User-defined widgets, being implemented as shell functions, User-defined widgets, being implemented as shell functions,
can execute any normal shell command. They can also run other widgets can execute any normal shell command. They can also run other widgets
(whether built-in or user-defined) using the tt(zle) builtin command. (whether built-in or user-defined) using the tt(zle) builtin command. The
The standard input of the function is closed to prevent external commands standard input of the function is redirected from /dev/null to prevent
from unintentionally blocking ZLE by reading from the terminal, but external commands from unintentionally blocking ZLE by reading from the
tt(read -k) or tt(read -q) can be used to read characters. Finally, terminal, but tt(read -k) or tt(read -q) can be used to read characters.
they can examine and edit the ZLE buffer being edited by Finally, they can examine and edit the ZLE buffer being edited by reading
reading and setting the special parameters described below. and setting the special parameters described below.
cindex(parameters, editor) cindex(parameters, editor)
cindex(parameters, zle) cindex(parameters, zle)

4
NEWS
View File

@ -14,6 +14,10 @@ expansion (see zshexpn(1)), so they could neither be quoted nor be the
result of parameter expansion. Examples: 's=command; $s -V ls' and result of parameter expansion. Examples: 's=command; $s -V ls' and
'\command -V ls' now work as expected. '\command -V ls' now work as expected.
Functions executed by ZLE widgets no longer have they standard input
closed, but is now redirected from /dev/null instead. That still guards
against user defined widgets inadvertently reading from the tty device.
Changes from 5.2 to 5.3.1 Changes from 5.2 to 5.3.1
------------------------- -------------------------

6
README
View File

@ -74,6 +74,12 @@ to undo the escaping with:
This is also needed if $vcs_info_msg_0_ is used to set $psvar. This is also needed if $vcs_info_msg_0_ is used to set $psvar.
4) functions executed by ZLE widgets no longer have they standard input
closed, but is now redirected from /dev/null instead. That still guards
against user defined widgets inadvertently reading from the tty device,
and addresses the antisocial behaviour of running a command with its
stdin closed.
Incompatibilities between 5.0.8 and 5.3 Incompatibilities between 5.0.8 and 5.3
---------------------------------------- ----------------------------------------

View File

@ -1485,6 +1485,13 @@ execzlefunc(Thingy func, char **args, int set_bindk)
int inuse = w->flags & WIDGET_INUSE; int inuse = w->flags & WIDGET_INUSE;
w->flags |= WIDGET_INUSE; w->flags |= WIDGET_INUSE;
if (osi > 0) {
/*
* Many commands don't like having a closed stdin, open on
* /dev/null instead
*/
open("/dev/null", O_RDWR | O_NOCTTY); /* ignore failure */
}
if (*args) { if (*args) {
largs = newlinklist(); largs = newlinklist();
addlinknode(largs, dupstring(w->u.fnnam)); addlinknode(largs, dupstring(w->u.fnnam));