summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/zle.yo12
-rw-r--r--NEWS4
-rw-r--r--README6
-rw-r--r--Src/Zle/zle_main.c7
5 files changed, 28 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 73d87ee62..f4a938dd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* 41284: Src/builtin.c, Test/B01cd.ztst: fix null dereference on
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index b65e3be64..bd0252f6e 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -750,12 +750,12 @@ sect(User-Defined Widgets)
cindex(widgets, user-defined)
User-defined widgets, being implemented as shell functions,
can execute any normal shell command. They can also run other widgets
-(whether built-in or user-defined) using the tt(zle) builtin command.
-The standard input of the function is closed to prevent external commands
-from unintentionally blocking ZLE by reading from the terminal, but
-tt(read -k) or tt(read -q) can be used to read characters. Finally,
-they can examine and edit the ZLE buffer being edited by
-reading and setting the special parameters described below.
+(whether built-in or user-defined) using the tt(zle) builtin command. The
+standard input of the function is redirected from /dev/null to prevent
+external commands from unintentionally blocking ZLE by reading from the
+terminal, but tt(read -k) or tt(read -q) can be used to read characters.
+Finally, they can examine and edit the ZLE buffer being edited by reading
+and setting the special parameters described below.
cindex(parameters, editor)
cindex(parameters, zle)
diff --git a/NEWS b/NEWS
index 568b1609a..44949b453 100644
--- a/NEWS
+++ b/NEWS
@@ -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
'\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
-------------------------
diff --git a/README b/README
index 432a35e76..30023dad9 100644
--- a/README
+++ b/README
@@ -74,6 +74,12 @@ to undo the escaping with:
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
----------------------------------------
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 6c271b5d0..be2b062b0 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1485,6 +1485,13 @@ execzlefunc(Thingy func, char **args, int set_bindk)
int 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) {
largs = newlinklist();
addlinknode(largs, dupstring(w->u.fnnam));