This is zsh.info, produced by makeinfo version 4.5 from ./zsh.texi.

INFO-DIR-SECTION Utilities
START-INFO-DIR-ENTRY
* ZSH: (zsh).                     The Z Shell Manual.
END-INFO-DIR-ENTRY


File: zsh.info,  Node: The zsh/zftp Module,  Next: The zsh/zle Module,  Prev: The zsh/terminfo Module,  Up: Zsh Modules

The zsh/zftp Module
===================

The zsh/zftp module makes available one builtin command:

zftp SUBCOMMAND [ ARGS ]
     The zsh/zftp module is a client for FTP (file transfer protocol).
     It is implemented as a builtin to allow full use of shell command
     line editing, file I/O, and job control mechanisms.  Often, users
     will access it via shell functions providing a more powerful
     interface; a set is provided with the zsh distribution and is
     described in *Note Zftp Function System::.  However, the zftp
     command is entirely usable in its own right.

     All commands consist of the command name zftp followed by the name
     of a subcommand.  These are listed below.  The return status of
     each subcommand is supposed to reflect the success or failure of
     the remote operation.  See a description of the variable
     ZFTP_VERBOSE for more information on how responses from the server
     may be printed.


Subcommands
-----------

open HOST [ USER [ PASSWORD [ ACCOUNT ] ] ]
     Open a new FTP session to HOST, which may be the name of a TCP/IP
     connected host or an IP number in the standard dot notation.
     Remaining arguments are passed to the login subcommand.  Note that
     if no arguments beyond HOST are supplied, open will _not_
     automatically call login.  If no arguments at all are supplied,
     open will use the parameters set by the params subcommand.

     After a successful open, the shell variables ZFTP_HOST, ZFTP_IP
     and ZFTP_SYSTEM are available; see `Variables' below.

login [ NAME [ PASSWORD [ ACCOUNT ] ] ]
user [ NAME [ PASSWORD [ ACCOUNT ] ] ]
     Login the user NAME with parameters PASSWORD and ACCOUNT.  Any of
     the parameters can be omitted, and will be read from standard
     input if needed (NAME is always needed).  If standard input is a
     terminal, a prompt for each one will be printed on standard error
     and PASSWORD will not be echoed.  If any of the parameters are not
     used, a warning message is printed.

     After a successful login, the shell variables ZFTP_USER,
     ZFTP_ACCOUNT and ZFTP_PWD are available; see `Variables' below.

     This command may be re-issued when a user is already logged in, and
     the server will first be reinitialized for a new user.

params [ HOST [ USER [ PASSWORD [ ACCOUNT ] ] ] ]
params -
     Store the given parameters for a later open command with no
     arguments.  Only those given on the command line will be
     remembered.  If no arguments are given, the parameters currently
     set are printed, although the password will appear as a line of
     stars; the return value is one if no parameters were set, zero
     otherwise.

     Any of the parameters may be specified as a `?', which may need to
     be quoted to protect it from shell expansion.  In this case, the
     appropriate parameter will be read from stdin as with the login
     subcommand, including special handling of PASSWORD.  If the `?' is
     followed by a string, that is used as the prompt for reading the
     parameter instead of the default message (any necessary
     punctuation and whitespace should be included at the end of the
     prompt).  The first letter of the parameter (only) may be quoted
     with a `\'; hence an argument "\\$word" guarantees that the string
     from the shell parameter $word will be treated literally, whether
     or not it begins with a `?'.

     If instead a single `-' is given, the existing parameters, if any,
     are deleted.  In that case, calling open with no arguments will
     cause an error.

     The list of parameters is not deleted after a close, however it
     will be deleted if the zsh/zftp module is unloaded.

     For example,

          zftp params ftp.elsewhere.xx juser '?Password for juser: '

     will store the host ftp.elsewhere.xx and the user juser and then
     prompt the user for the corresponding password with the given
     prompt.

test
     Test the connection; if the server has reported that it has closed
     the connection (maybe due to a timeout), return status 2; if no
     connection was open anyway, return status 1; else return status 0.
     The test subcommand is silent, apart from messages printed by the
     $ZFTP_VERBOSE mechanism, or error messages if the connection
     closes.  There is no network overhead for this test.

     The test is only supported on systems with either the select(2) or
     poll(2) system calls; otherwise the message `not supported on this
     system' is printed instead.

     The test subcommand will automatically be called at the start of
     any other subcommand for the current session when a connection is
     open.

cd DIRECTORY
     Change the remote directory to DIRECTORY.  Also alters the shell
     variable ZFTP_PWD.

cdup
     Change the remote directory to the one higher in the directory
     tree.  Note that cd .. will also work correctly on non-UNIX
     systems.

dir [ ARGS... ]
     Give a (verbose) listing of the remote directory.  The ARGS are
     passed directly to the server. The command's behaviour is
     implementation dependent, but a UNIX server will typically
     interpret ARGS as arguments to the ls command and with no
     arguments return the result of `ls -l'. The directory is listed to
     standard output.

ls [ ARGS ]
     Give a (short) listing of the remote directory.  With no ARGS,
     produces a raw list of the files in the directory, one per line.
     Otherwise, up to vagaries of the server implementation, behaves
     similar to dir.

type [ TYPE ]
     Change the type for the transfer to TYPE, or print the current type
     if TYPE is absent.  The allowed values are `A' (ASCII), `I'
     (Image, i.e. binary), or `B' (a synonym for `I').

     The FTP default for a transfer is ASCII.  However, if zftp finds
     that the remote host is a UNIX machine with 8-bit byes, it will
     automatically switch to using binary for file transfers upon open.
     This can subsequently be overridden.

     The transfer type is only passed to the remote host when a data
     connection is established; this command involves no network
     overhead.

ascii
     The same as type A.

binary
     The same as type I.

mode [ S | B ]
     Set the mode type to stream (S) or block (B).  Stream mode is the
     default; block mode is not widely supported.

remote FILES...
local [ FILES... ]
     Print the size and last modification time of the remote or local
     files.  If there is more than one item on the list, the name of the
     file is printed first.  The first number is the file size, the
     second is the last modification time of the file in the format
     CCYYMMDDhhmmSS consisting of year, month, date, hour, minutes and
     seconds in GMT.  Note that this format, including the length, is
     guaranteed, so that time strings can be directly compared via the
     [[ builtin's < and > operators, even if they are too long to be
     represented as integers.

     Not all servers support the commands for retrieving this
     information.  In that case, the remote command will print nothing
     and return status 2, compared with status 1 for a file not found.

     The local command (but not remote) may be used with no arguments,
     in which case the information comes from examining file descriptor
     zero.  This is the same file as seen by a put command with no
     further redirection.

get FILE [...]
     Retrieve all FILEs from the server, concatenating them and sending
     them to standard output.

put FILE [...]
     For each FILE, read a file from standard input and send that to
     the remote host with the given name.

append FILE [...]
     As put, but if the remote FILE already exists, data is appended to
     it instead of overwriting it.

getat FILE POINT
putat FILE POINT
appendat FILE POINT
     Versions of get, put and append which will start the transfer at
     the given POINT in the remote FILE.  This is useful for appending
     to an incomplete local file.  However, note that this ability is
     not universally supported by servers (and is not quite the
     behaviour specified by the standard).

delete FILE [...]
     Delete the list of files on the server.

mkdir DIRECTORY
     Create a new directory DIRECTORY on the server.

rmdir DIRECTORY
     Delete the directory DIRECTORY  on the server.

rename OLD-NAME NEW-NAME
     Rename file OLD-NAME to NEW-NAME on the server.

site ARGS...
     Send a host-specific command to the server.  You will probably
     only need this if instructed by the server to use it.

quote ARGS...
     Send the raw FTP command sequence to the server.  You should be
     familiar with the FTP command set as defined in RFC959 before doing
     this.  Useful commands may include STAT and HELP.  Note also the
     mechanism for returning messages as described for the variable
     ZFTP_VERBOSE below, in particular that all messages from the
     control connection are sent to standard error.

close
quit
     Close the current data connection.  This unsets the shell
     parameters ZFTP_HOST, ZFTP_IP, ZFTP_SYSTEM, ZFTP_USER,
     ZFTP_ACCOUNT, ZFTP_PWD, ZFTP_TYPE and ZFTP_MODE.

session [ SESSNAME ]
     Allows multiple FTP sessions to be used at once.  The name of the
     session is an arbitrary string of characters; the default session
     is called `default'.  If this command is called without an
     argument, it will list all the current sessions; with an argument,
     it will either switch to the existing session called SESSNAME, or
     create a new session of that name.

     Each session remembers the status of the connection, the set of
     connection-specific shell parameters (the same set as are unset
     when a connection closes, as given in the description of close),
     and any user parameters specified with the params subcommand.
     Changing to a previous session restores those values; changing to
     a new session initialises them in the same way as if zftp had just
     been loaded.  The name of the current session is given by the
     parameter ZFTP_SESSION.

rmsession [ SESSNAME ]
     Delete a session; if a name is not given, the current session is
     deleted.  If the current session is deleted, the earliest existing
     session becomes the new current session, otherwise the current
     session is not changed.  If the session being deleted is the only
     one, a new session called `default' is created and becomes the
     current session; note that this is a new session even if the
     session being deleted is also called `default'. It is recommended
     that sessions not be deleted while background commands which use
     zftp are still active.


Parameters
----------

The following shell parameters are used by zftp.  Currently none of
them are special.

ZFTP_TMOUT
     Integer.  The time in seconds to wait for a network operation to
     complete before returning an error.  If this is not set when the
     module is loaded, it will be given the default value 60.  A value
     of zero turns off timeouts.  If a timeout occurs on the control
     connection it will be closed.  Use a larger value if this occurs
     too frequently.

ZFTP_IP
     Readonly.  The IP address of the current connection in dot
     notation.

ZFTP_HOST
     Readonly.  The hostname of the current remote server.  If the host
     was opened as an IP number, ZFTP_HOST contains that instead; this
     saves the overhead for a name lookup, as IP numbers are most
     commonly used when a nameserver is unavailable.

ZFTP_SYSTEM
     Readonly.  The system type string returned by the server in
     response to an FTP SYST request.  The most interesting case is a
     string beginning "UNIX Type: L8", which ensures maximum
     compatibility with a local UNIX host.

ZFTP_TYPE
     Readonly.  The type to be used for data transfers , either `A' or
     `I'.   Use the type subcommand to change this.

ZFTP_USER
     Readonly.  The username currently logged in, if any.

ZFTP_ACCOUNT
     Readonly.  The account name of the current user, if any.  Most
     servers do not require an account name.

ZFTP_PWD
     Readonly.  The current directory on the server.

ZFTP_CODE
     Readonly.  The three digit code of the last FTP reply from the
     server as a string.  This can still be read after the connection
     is closed, and is not changed when the current session changes.

ZFTP_REPLY
     Readonly.  The last line of the last reply sent by the server.
     This can still be read after the connection is closed, and is not
     changed when the current session changes.

ZFTP_SESSION
     Readonly.  The name of the current FTP session; see the
     description of the session subcommand.

ZFTP_PREFS
     A string of preferences for altering aspects of zftp's behaviour.
     Each preference is a single character.  The following are defined:

    P
          Passive:  attempt to make the remote server initiate data
          transfers.  This is slightly more efficient than sendport
          mode.  If the letter S occurs later in the string, zftp will
          use sendport mode if passive mode is not available.

    S
          Sendport:  initiate transfers by the FTP PORT command.  If
          this occurs before any P in the string, passive mode will
          never be attempted.

    D
          Dumb:  use only the bare minimum of FTP commands.  This
          prevents the variables ZFTP_SYSTEM and ZFTP_PWD from being
          set, and will mean all connections default to ASCII type.  It
          may prevent ZFTP_SIZE from being set during a transfer if the
          server does not send it anyway (many servers do).


     If ZFTP_PREFS is not set when zftp is loaded, it will be set to a
     default of `PS', i.e. use passive mode if available, otherwise
     fall back to sendport mode.

ZFTP_VERBOSE
     A string of digits between 0 and 5 inclusive, specifying which
     responses from the server should be printed.  All responses go to
     standard error.  If any of the numbers 1 to 5 appear in the string,
     raw responses from the server with reply codes beginning with that
     digit will be printed to standard error.  The first digit of the
     three digit reply code is defined by RFC959 to correspond to:

    1.
          A positive preliminary reply.

    2.
          A positive completion reply.

    3.
          A positive intermediate reply.

    4.
          A transient negative completion reply.

    5.
          A permanent negative completion reply.


     It should be noted that, for unknown reasons, the reply `Service
     not available', which forces termination of a connection, is
     classified as 421, i.e. `transient negative', an interesting
     interpretation of the word `transient'.

     The code 0 is special:  it indicates that all but the last line of
     multiline replies read from the server will be printed to standard
     error in a processed format.  By convention, servers use this
     mechanism for sending information for the user to read.  The
     appropriate reply code, if it matches the same response, takes
     priority.

     If ZFTP_VERBOSE is not set when zftp is loaded, it will be set to
     the default value 450, i.e., messages destined for the user and
     all errors will be printed.  A null string is valid and specifies
     that no messages should be printed.


Functions
---------

zftp_chpwd
     If this function is set by the user, it is called every time the
     directory changes on the server, including when a user is logged
     in, or when a connection is closed.  In the last case, $ZFTP_PWD
     will be unset; otherwise it will reflect the new directory.

zftp_progress
     If this function is set by the user, it will be called during a
     get, put or append operation each time sufficient data has been
     received from the host.  During a get, the data is sent to
     standard output, so it is vital that this function should write to
     standard error or directly to the terminal, _not_ to standard
     output.

     When it is called with a transfer in progress, the following
     additional shell parameters are set:

    ZFTP_FILE
          The name of the remote file being transferred from or to.

    ZFTP_TRANSFER
          A G for a get operation and a P for a put operation.

    ZFTP_SIZE
          The total size of the complete file being transferred: the
          same as the first value provided by the remote and local
          subcommands for a particular file.  If the server cannot
          supply this value for a remote file being retrieved, it will
          not be set.  If input is from a pipe the value may be
          incorrect and correspond simply to a full pipe buffer.

    ZFTP_COUNT
          The amount of data so far transferred; a number between zero
          and $ZFTP_SIZE, if that is set.  This number is always
          available.


     The function is initially called with ZFTP_TRANSFER set
     appropriately and ZFTP_COUNT set to zero.  After the transfer is
     finished, the function will be called one more time with
     ZFTP_TRANSFER set to GF or PF, in case it wishes to tidy up.  It
     is otherwise never called twice with the same value of ZFTP_COUNT.

     Sometimes the progress meter may cause disruption.  It is up to the
     user to decide whether the function should be defined and to use
     unfunction when necessary.


Problems
--------

A connection may not be opened in the left hand side of a pipe as this
occurs in a subshell and the file information is not updated in the main
shell.  In the case of type or mode changes or closing the connection
in a subshell, the information is returned but variables are not
updated until the next call to zftp.  Other status changes in subshells
will not be reflected by changes to the variables (but should be
otherwise harmless).

Deleting sessions while a zftp command is active in the background can
have unexpected effects, even if it does not use the session being
deleted.  This is because all shell subprocesses share information on
the state of all connections, and deleting a session changes the
ordering of that information.

On some operating systems, the control connection is not valid after a
fork(), so that operations in subshells, on the left hand side of a
pipeline, or in the background are not possible, as they should be.
This is presumably a bug in the operating system.


File: zsh.info,  Node: The zsh/zle Module,  Next: The zsh/zleparameter Module,  Prev: The zsh/zftp Module,  Up: Zsh Modules

The zsh/zle Module
==================

The zsh/zle module contains the Zsh Line Editor.  See *Note Zsh Line
Editor::.


File: zsh.info,  Node: The zsh/zleparameter Module,  Next: The zsh/zprof Module,  Prev: The zsh/zle Module,  Up: Zsh Modules

The zsh/zleparameter Module
===========================

The zsh/zleparameter module defines two special parameters that can be
used to access internal information of the Zsh Line Editor (see *Note
Zsh Line Editor::).

keymaps
     This array contains the names of the keymaps currently defined.

widgets
     This associative array contains one entry per widget defined. The
     name of the widget is the key and the value gives information
     about the widget. It is either the string `builtin' for builtin
     widgets, a string of the form `user:NAME' for user-defined widgets,
     where NAME is the name of the shell function implementing the
     widget, or it is a string of the form `completion:TYPE:NAME', for
     completion widgets. In the last case TYPE is the name of the
     builtin widgets the completion widget imitates in its behavior and
     NAME is the name of the shell function implementing the completion
     widget.



File: zsh.info,  Node: The zsh/zprof Module,  Next: The zsh/zpty Module,  Prev: The zsh/zleparameter Module,  Up: Zsh Modules

The zsh/zprof Module
====================

When loaded, the zsh/zprof causes shell functions to be profiled.  The
profiling results can be obtained with the zprof builtin command made
available by this module.  There is no way to turn profiling off other
than unloading the module.

zprof [ -c ]
     Without the -c option, zprof lists profiling results to standard
     output.  The format is comparable to that of commands like gprof.

     At the top there is a summary listing all functions that were
     called at least once.  This summary is sorted in decreasing order
     of the amount of time spent in each.  The lines contain the number
     of the function in order, which is used in other parts of the list
     in suffixes of the form `[NUM]', then the number of calls made to
     the function.  The next three columns list the time in
     milliseconds spent in the function and its descendents, the average
     time in milliseconds spent in the function and its descendents per
     call and the percentage of time spent in all shell functions used
     in this function and its descendents.  The following three columns
     give the same information, but counting only the time spent in the
     function itself.  The final column shows the name of the function.

     After the summary, detailed information about every function that
     was invoked is listed, sorted in decreasing order of the amount of
     time spent in each function and its descendents.  Each of these
     entries consists of descriptions for the functions that called the
     function described, the function itself, and the functions that
     were called from it.  The description for the function itself has
     the same format as in the summary (and shows the same
     information).  The other lines don't show the number of the
     function at the beginning and have their function named indented to
     make it easier to distinguish the line showing the function
     described in the section from the surrounding lines.

     The information shown in this case is almost the same as in the
     summary, but only refers to the call hierarchy being displayed.
     For example, for a calling function the column showing the total
     running time lists the time spent in the described function and
     its descendents only for the times when it was called from that
     particular calling function.  Likewise, for a called function,
     this columns lists the total time spent in the called function and
     its descendents only for the times when it was called from the
     function described.

     Also in this case, the column showing the number of calls to a
     function also shows a slash and then the total number of
     invocations made to the called function.

     As long as the zsh/zprof module is loaded, profiling will be done
     and multiple invocations of the zprof builtin command will show the
     times and numbers of calls since the module was loaded.  With the
     -c option, the zprof builtin command will reset its internal
     counters and will not show the listing.  )


File: zsh.info,  Node: The zsh/zpty Module,  Next: The zsh/zselect Module,  Prev: The zsh/zprof Module,  Up: Zsh Modules

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.



File: zsh.info,  Node: The zsh/zselect Module,  Next: The zsh/zutil Module,  Prev: The zsh/zpty Module,  Up: Zsh Modules

The zsh/zselect Module
======================

The zsh/zselect module makes available one builtin command:

zselect [ -rwe -t TIMEOUT -a ARRAY ] [ FD ... ]
     The zselect builtin is a front-end to the `select' system call,
     which blocks until a file descriptor is ready for reading or
     writing, or has an error condition, with an optional timeout.  If
     this is not available on your system, the command prints an error
     message and returns status 2 (normal errors return status 1).  For
     more information, see your systems documentation for man page
     select(3).  Note there is no connection with the shell builtin of
     the same name.

     Arguments and options may be intermingled in any order.  Non-option
     arguments are file descriptors, which must be decimal integers.  By
     default, file descriptors are to be tested for reading, i.e.
     zselect will return when data is available to be read from the
     file descriptor, or more precisely, when a read operation from the
     file descriptor will not block.  After a -r, -w and -e, the given
     file descriptors are to be tested for reading, writing, or error
     conditions.  These options and an arbitrary list of file
     descriptors may be given in any order.

     (The presence of an `error condition' is not well defined in the
     documentation for many implementations of the select system call.
     According to recent versions of the POSIX specification, it is
     really an _exception_ condition, of which the only standard
     example is out-of-band data received on a socket.  So zsh users
     are unlikely to find the -e option useful.)

     The option `-t TIMEOUT' specifies a timeout in hundredths of a
     second.  This may be zero, in which case the file descriptors will
     simply be polled and zselect will return immediately.  It is
     possible to call zselect with no file descriptors and a non-zero
     timeout for use as a finer-grained replacement for `sleep'; not,
     however, the return status is always 1 for a timeout.

     The option `-a ARRAY' indicates that array should be set to
     indicate the file descriptor(s) which are ready.  If the option is
     not given, the array reply will be used for this purpose.  The
     array will contain a string similar to the arguments for zselect.
     For example,

          zselect -t 0 -r 0 -w 1

     might return immediately with status 0 and $reply containing `-r 0
     -w 1' to show that both file descriptors are ready for the
     requested operations.

     The option `-A ASSOC' indicates that the associative array assoc
     should be set to indicate the file descriptor(s) which are ready.
     This option overrides the option -a, nor will reply be modified.
     The keys of assoc are the file descriptors, and the corresponding
     values are any of the characters `rwe' to indicate the condition.

     The command returns 0 if some file descriptors are ready for
     reading.  If the operation timed out, or a timeout of 0 was given
     and no file descriptors were ready, or there was an error, it
     returns status 1 and the array will not be set (nor modified in
     any way).  If there was an error in the select operation the
     appropriate error message is printed.



File: zsh.info,  Node: The zsh/zutil Module,  Prev: The zsh/zselect Module,  Up: Zsh Modules

The zsh/zutil Module
====================

The zsh/zutil module only adds some builtins:

zstyle [ -L ]
zstyle [ -e | - | -- ] PATTERN STYLE STRINGS ...
zstyle -d [ PATTERN [ STYLES ... ] ]
zstyle -g NAME [ PATTERN [ STYLE ] ]
zstyle -abs CONTEXT STYLE NAME [ SEP ]
zstyle -Tt CONTEXT STYLE [ STRINGS ...]
zstyle -m CONTEXT STYLE PATTERN
     This builtin command is used to define and lookup styles.  Styles
     are pairs of names and values, where the values consist of any
     number of strings.  They are stored together with patterns and
     lookup is done by giving a string, called the `context', which is
     compared to the patterns.  The definition stored for the first
     matching pattern will be returned.

     For ordering of comparisons, patterns are searched from most
     specific to least specific, and patterns that are equally specific
     keep the order in which they were defined.  A pattern is
     considered to be more specific than another if it contains more
     components (substrings separated by colons) or if the patterns for
     the components are more specific, where simple strings are
     considered to be more specific than patterns and complex patterns
     are considered to be more specific than the pattern `*'.

     The first form (without arguments) lists the definitions in the
     order zstyle will test them. If the -L option is given, listing is
     done in the form of calls to zstyle.  Forms with arguments:

    zstyle [ - | -- | -e ] PATTERN STYLE STRINGS ...
          Defines the given STYLE for the PATTERN with the STRINGS as
          the value.  If the -e option is given, the STRINGS will be
          concatenated (separated by spaces) and the resulting string
          will be evaluated (in the same way as it is done by the eval
          builtin command) when the style is looked up.  In this case
          the parameter `reply' must be assigned to set the strings
          returned after the evaluation.  Before evaluating the value,
          reply is unset, and if it is still unset after the
          evaluation, the style is treated as if it were not set.

    zstyle -d [ PATTERN [ STYLES ... ] ]
          Delete style definitions. Without arguments all definitions
          are deleted, with a PATTERN all definitions for that pattern
          are deleted and if any STYLES are given, then only those
          styles are deleted for the PATTERN.

    zstyle -g NAME [ PATTERN [ STYLE ] ]
          Retrieve a style definition. The NAME is used as the name of
          an array in which the results are stored. Without any further
          arguments, all PATTERNS defined are returned. With a PATTERN
          the styles defined for that pattern are returned and with
          both a PATTERN and a STYLE, the value strings of that
          combination is returned.


     The other forms can be used to look up or test patterns.

    zstyle -s CONTEXT STYLE NAME [ SEP ]
          The parameter NAME is set to the value of the style
          interpreted as a string.  If the value contains several
          strings they are concatenated with spaces (or with the SEP
          string if that is given) between them.

    zstyle -b CONTEXT STYLE NAME
          The value is stored in NAME as a boolean, i.e. as the string
          `yes' if the value has only one string and that string is
          equal to one of `yes', `true', `on', or `1'. If the value is
          any other string or has more than one string, the parameter
          is set to `no'.

    zstyle -a CONTEXT STYLE NAME
          The value is stored in NAME as an array. If NAME is declared
          as an associative array,  the first, third, etc. strings are
          used as the keys and the other strings are used as the values.

    zstyle -t CONTEXT STYLE [ STRINGS ...]
    zstyle -T CONTEXT STYLE [ STRINGS ...]
          Test the value of a style, i.e. the -t option only returns a
          status (sets $?).  Without any STRINGS the return status is
          zero if the style is defined for at least one matching
          pattern, has only one string in its value, and that is equal
          to one of `true', `yes', `on' or `1'. If any STRINGS are
          given the status is zero if and only if at least one of the
          STRINGS is equal to at least one of the strings in the value.
          If the style is not defined, the status is 2.

          The -T option tests the values of the style like -t, but it
          returns zero (rather than 2) if the style is not defined for
          any matching pattern.

    zstyle -m CONTEXT STYLE PATTERN
          Match a value. Returns status zero if the PATTERN matches at
          least one of the strings in the value.


zformat -f PARAM FORMAT SPECS ...
zformat -a ARRAY SEP SPECS ...
     This builtin provides two different forms of formatting. The first
     form is selected with the -f option. In this case the FORMAT
     string will be modified by replacing sequences starting with a
     percent sign in it with strings from the SPECS.  Each SPEC should
     be of the form `CHAR:STRING' which will cause every appearance of
     the sequence `%CHAR' in FORMAT to be replaced by the STRING.  The
     `%' sequence may also contain optional minimum and maximum field
     width specifications between the `%' and the `CHAR' in the form
     `%MIN.MAXc', i.e. the minimum field width is given first and if
     the maximum field width is used, it has to be preceded by a dot.
     Specifying a minimum field width makes the result be padded with
     spaces to the right if the STRING is shorter than the requested
     width.  Padding to the left can be achieved by giving a negative
     minimum field width.  If a maximum field width is specified, the
     STRING will be truncated after that many characters.  After all
     `%' sequences for the given SPECS have been processed, the
     resulting string is stored in the parameter PARAM.

     The %-escapes also understand ternary expressions in the form used
     by prompts.  The % is followed by a `(' and then an ordinary
     format specifier character as described above.  There may be a set
     of digits either before or after the `('; these specify a test
     number, which defaults to zero.  Negative numbers are also
     allowed.  An arbitrary delimiter character follows the format
     specifier, which is followed by a piece of `true' text, the
     delimiter character again, a piece of `false' text, and a closing
     parenthesis.  The complete expression (without the digits) thus
     looks like `%(X.TEXT1.TEXT2)', except that the `.' character is
     arbitrary.  The value given for the format specifier in the
     CHAR:STRING expressions is evaluated as a mathematical expression,
     and compared with the test number.  If they are the same, TEXT1 is
     output, else TEXT2 is output.  A parenthesis may be escaped in
     TEXT2 as %).  Either of TEXT1 or TEXT2 may contain nested
     %-escapes.

     For example:

          zformat -f REPLY "The answer is '%3(c.yes.no)'." c:3

     outputs "The answer is 'yes'." to REPLY since the value for the
     format specifier c is 3, agreeing with the digit argument to the
     ternary expression.

     The second form, using the -a option, can be used for aligning
     strings.  Here, the SPECS are of the form `LEFT:RIGHT' where
     `LEFT' and `RIGHT' are arbitrary strings.  These strings are
     modified by replacing the colons by the SEP string and padding the
     LEFT strings with spaces to the right so that the SEP strings in
     the result (and hence the RIGHT strings after them) are all
     aligned if the strings are printed below each other.  All strings
     without a colon are left unchanged and all strings with an empty
     RIGHT string have the trailing colon removed.  In both cases the
     lengths of the strings are not used to determine how the other
     strings are to be aligned.  The resulting strings are stored in
     the ARRAY.

zregexparse
     This implements some internals of the _regex_arguments function.

zparseopts [ -D ] [ -K ] [ -E ] [ -a ARRAY ] [ -A ASSOC ] SPECS
     This builtin simplifies the parsing of options in positional
     parameters, i.e. the set of arguments given by $*.  Each SPEC
     describes one option and must be of the form `OPT[=ARRAY]'.  If an
     option described by OPT is found in the positional parameters it
     is copied into the ARRAY specified with the -a option; if the
     optional `=ARRAY' is given, it is instead copied into that array.

     Note that it is an error to give any SPEC without an `=ARRAY'
     unless one of the -a or -A options is used.

     Unless the -E option is given, parsing stops at the first string
     that isn't described by one of the SPECS.  Even with -E, parsing
     always stops at a positional parameter equal to `-' or `--'.

     The OPT description must be one of the following.  Any of the
     special characters can appear in the option name provided it is
     preceded by a backslash.

    NAME
    NAME+
          The NAME is the name of the option without the leading `-'.
          To specify a GNU-style long option, one of the usual two
          leading `-' must be included in NAME; for example, a `-file'
          option is represented by a NAME of `-file'.

          If a `+' appears after NAME, the option is appended to ARRAY
          each time it is found in the positional parameters; without
          the `+' only the _last_ occurrence of the option is preserved.

          If one of these forms is used, the option takes no argument,
          so parsing stops if the next positional parameter does not
          also begin with `-' (unless the -E option is used).

    NAME:
    NAME:-
    NAME::
          If one or two colons are given, the option takes an argument;
          with one colon, the argument is mandatory and with two colons
          it is optional.  The argument is appended to the ARRAY after
          the option itself.

          An optional argument is put into the same array element as
          the option name (note that this makes empty strings as
          arguments indistinguishable).  A mandatory argument is added
          as a separate element unless the `:-' form is used, in which
          case the argument is put into the same element.

          A `+' as described above may appear between the NAME and the
          first colon.


     The options of zparseopts itself are:

    -a ARRAY
          As described above, this names the default array in which to
          store the recognised options.

    -A ASSOC
          If this is given, the options and their values are also put
          into an associative array with the option names as keys and
          the arguments (if any) as the values.

    -D
          If this option is given, all options found are removed from
          the positional parameters of the calling shell or shell
          function, up to but not including any not described by the
          SPECS.  This is similar to using the shift builtin.

    -K
          With this option, the arrays specified with the -a and -A
          options and with the `=ARRAY' forms are kept unchanged when
          none of the SPECS for them is used.  This allows assignment
          of default values to them before calling zparseopts.

    -E
          This changes the parsing rules to _not_ stop at the first
          string that isn't described by one of the SPECs.  It can be
          used to test for or (if used together with -D) extract
          options and their arguments, ignoring all other options and
          arguments that may be in the positional parameters.


     For example,

          set -- -a -bx -c y -cz baz -cend
          zparseopts a=foo b:=bar c+:=bar

     will have the effect of

          foo=(-a)
          bar=(-b x -c y -c z)

     The arguments from `baz' on will not be used.

     As an example for the -E option, consider:

          set -- -a x -b y -c z arg1 arg2
          zparseopts -E -D b:=bar

     will have the effect of

          bar=(-b y)
          set -- -a x -c z arg1 arg2

     I.e., the option -b and its arguments are taken from the
     positional parameters and put into the array bar.



File: zsh.info,  Node: TCP Function System,  Next: Zftp Function System,  Prev: Zsh Modules,  Up: Top

TCP Function System
*******************

Description
===========

A module zsh/net/tcp is provided to provide network I/O over TCP/IP
from within the shell; see its description in *Note Zsh Modules:: .
This manual page describes a function suite based on the module.  If
the module is installed, the functions are usually installed at the
same time, in which case they will be available for autoloading in the
default function search path.  In addition to the zsh/net/tcp module,
the zsh/zselect module is used to implement timeouts on read
operations.  For troubleshooting tips, consult the corresponding advice
for the zftp functions described in *Note Zftp Function System:: .

There are functions corresponding to the basic I/O operations open,
close, read and send, named tcp_open etc., as well as a function
tcp_expect for pattern match analysis of data read as input.  The
system makes it easy to receive data from and send data to multiple
named sessions at once.  In addition, it can be linked with the shell's
line editor in such a way that input data is automatically shown at the
terminal.  Other facilities available including logging, filtering and
configurable output prompts.

To use the system where it is available, it should be enough to
`autoload -U tcp_open' and run tcp_open as documented below to start a
session.  The tcp_open function will autoload the remaining functions.

* Menu:

* TCP Functions::
* TCP Parameters::
* TCP Examples::
* TCP Bugs::

