about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-08-11 08:48:48 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2015-08-11 08:55:23 -0700
commita01f29c11de0df084a9a1e6b932b2937936d2119 (patch)
tree0fa2efb5d6caa67f935eda750f2bf6f8d476a66f
parent1af2e6e02d5cb8ca8d11f107b670cddfd10a7e81 (diff)
downloadzsh-a01f29c11de0df084a9a1e6b932b2937936d2119.tar.gz
zsh-a01f29c11de0df084a9a1e6b932b2937936d2119.tar.xz
zsh-a01f29c11de0df084a9a1e6b932b2937936d2119.zip
36092: return the zpty master file descriptor in $REPLY for use with "zle -F" etc.
-rw-r--r--ChangeLog3
-rw-r--r--Doc/Zsh/mod_zpty.yo9
-rw-r--r--Src/Modules/zpty.c2
3 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c2274718b..59ed6f638 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-08-11  Barton E. Schaefer  <schaefer@zsh.org>
 
+	* 36092: Doc/Zsh/mod_zpty.yo, Src/Modules/zpty.c: return the pty
+	master file descriptor in $REPLY for use with "zle -F" etc.
+
 	* 36090: Src/init.c: keep signals queued for preprompt()
 
 2015-08-11  Oliver Kiddle <opk@zsh.org>
diff --git a/Doc/Zsh/mod_zpty.yo b/Doc/Zsh/mod_zpty.yo
index 340f98314..44b375a3c 100644
--- a/Doc/Zsh/mod_zpty.yo
+++ b/Doc/Zsh/mod_zpty.yo
@@ -18,6 +18,15 @@ characters are echoed.
 
 With the tt(-b) option, input to and output from the pseudo-terminal are
 made non-blocking.
+
+The shell parameter tt(REPLY) is set to the file descriptor assigned to
+the master side of the pseudo-terminal.  This allows the terminal to be
+monitored with ZLE descriptor handlers (see ifzman(zmanref(zshzle))\
+ifnzman(noderef(Zle Builtins))) or manipulated with tt(sysread) and
+tt(syswrite) (see ifzman(THE ZSH/SYSTEM MODULE in zmanref(zshmodules))\
+ifnzman(noderef(The zsh/system Module))).  em(Warning): Use of tt(sysread)
+and tt(syswrite) is em(not) recommended, use tt(zpty -r) and tt(zpty -w)
+unless you know exactly what you are doing.
 )
 item(tt(zpty) tt(-d) [ var(name) ... ])(
 The second form, with the tt(-d) option, is used to delete commands
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 7b6130c6f..12e42b5bd 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -463,6 +463,8 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
 #endif
 	    errno == EINTR));
 
+    setiparam("REPLY", master);
+
     return 0;
 }