GNU Info

Info Node: (zsh.info)The zsh/zpty Module

(zsh.info)The zsh/zpty Module


Next: The zsh/zutil Module Prev: The zsh/zprof Module Up: Zsh Modules
Enter node , (file) or (file)node

The zsh/zpty Module
===================

The zsh/zpty module offers one builtin:

zpty [ -e ] [ -b ] NAME [ ARG ... ]
     The arguments following NAME are concatenated with spaces between,
     then executed as a command, as if passed to the eval builtin.  The
     command runs under a newly assigned pseudo-terminal; this is
     useful for running commands non-interactively which expect an
     interactive environment.  The NAME is not part of the command, but
     is used to refer to this command in later calls to zpty.

     With the -e option, the pseudo-terminal is set up so that input
     characters are echoed.

     With the -b option, input to and output from the pseudo-terminal
     are made non-blocking.

zpty -d [ NAMES ... ]
     The second form, with the -d option, is used to delete commands
     previously started, by supplying a list of their NAMEs.  If no
     NAMES are given, all commands are deleted.  Deleting a command
     causes the HUP signal to be sent to the corresponding process.

zpty -w [ -n ] NAME [ STRINGS ... ]
     The -w option can be used to send the to command NAME the given
     STRINGS as input (separated by spaces).  If the -n option is _not_
     given, a newline is added at the end.

     If no STRINGS are provided, the standard input is copied to the
     pseudo-terminal; this may stop before copying the full input if the
     pseudo-terminal is non-blocking.

     Note that the command under the pseudo-terminal sees this input as
     if it were typed, so beware when sending special tty driver
     characters such as word-erase, line-kill, and end-of-file.

zpty -r [ -t ] NAME [ PARAM [ PATTERN ] ]
     The -r option can be used to read the output of the command NAME.
     With only a NAME argument, the output read is copied to the
     standard output.  Unless the pseudo-terminal is non-blocking,
     copying continues until the command under the pseudo-terminal
     exits; when non-blocking, only as much output as is immediately
     available is copied.  The return value is zero if any output is
     copied.

     When also given a PARAM argument, at most one line is read and
     stored in the parameter named PARAM.  Less than a full line may be
     read if the pseudo-terminal is non-blocking.  The return value is
     zero if at least one character is stored in PARAM.

     If a PATTERN is given as well, output is read until the whole
     string read matches the PATTERN, even in the non-blocking case.
     The return value is zero if the string read matches the pattern,
     or if the command has exited but at least one character could
     still be read.  As of this writing, a maximum of one megabyte of
     output can be consumed this way; if a full megabyte is read
     without matching the pattern, the return value is non-zero.

     In all cases, the return value is non-zero if nothing could be
     read, and is 2 if this is because the command has finished.

     If the -r option is combined with the -t option, zpty tests
     whether output is available before trying to read.  If no output is
     available, zpty immediately returns the value 1.

zpty -t NAME
     The -t option without the -r option can be used to test whether
     the command NAME is still running.  It returns a zero value if the
     command is running and a non-zero value otherwise.

zpty [ -L ]
     The last form, without any arguments, is used to list the commands
     currently defined.  If the -L option is given, this is done in the
     form of calls to the zpty builtin.


automatically generated by info2www version 1.2.2.9