gsub [-habekKnr] [-o address] [-f rcprog] [-l rclib] [-p state] categories...
Subscribe to messages on the Gale messaging system. Command-line arguments specify which messages to receive and how to format the messages; messages are written to standard output. By default, gsub runs in the background so that you can continue your work; messages will be displayed on your terminal as they occur. (This is similar to the way "write" or "talk" deliver messages to your screen.) If gsub is run twice on the same terminal, the second gsub will terminate the first, so you can simply re-run "gsub" with different parameters or environment variables to reconfigure your session.
Without command-line arguments or variables (like GALE_GSUB or GALE_SUBS) to the contrary, gsub will subscribe to your personal messages only. Categories specified on the command line are added to the subscription list.
Gsub's behavior may be customized with several configuration variables: GALE_CONF, GALE_DIR, GALE_DOMAIN, GALE_GSUB, GALE_PROXY, GALE_SUBS, GALE_SYS_DIR.
You can control what happens to messages by writing a "gsubrc". This is a program, written in any programming language you like (but usually a scripting language like Perl or the Bourne shell), which is executed every time a message is received; gsub looks for this program in in "$HOME/.gale/gsubrc" by default. The message's attributes are set in environment variables, and the message body is sent to the program's standard input. The program can output the message to the terminal (formatted however it wants), or it can log the message to a file, respond automatically to the message, or take any other action the user desires.
If no such program exists, gsub uses an internal message formatter. It is often useful to call this formatter from your own gsubrc, so you can do so by running "gsub -r". For example, a simple "killfile" gsubrc might examine the message's sender, terminate immediately if the sender is "undesirable", or otherwise call "gsub -r" to format the message exactly as it would have been otherwise.
The name of the gsubrc program can be changed with the "-f" argument, so you can switch between multiple formatters. Advanced programmers can specify a shared library with "-l" that will be loaded by gsub and called to format messages. Refer to the "gsubrc.h" file installed in the system include directory for details of the shared library gsub interface.
The best way to learn how to write "gsubrc" scripts is to run "gsub -f /usr/bin/env" and send yourself a message. All active configuration variables will be in the environment (even if they came from a configuration file). Additional variables describe the message. "$GALE_CATEGORY" contains the message category and "$GALE_SIGNED" contains the sender's verified ID (if any). Lots of variables of the form "$HEADER_..." contain information about the message's content.
gsend, Categories, Contributed gsubrc Archive