NAME
    exixpand - Wrap exim -be, providing readline and variable substitution

USAGE
    exixpand [--help|--version]

DESCRIPTION
    exixpand (pronounced exi-spand) is a wrapper for exim's expansion
    testing function (-be). It provides readline support via perl's
    Term::ReadLine module and also provides variable interpolations. The
    main intention of being able to track variables is to be able to test
    different values for variables without modifying the expansion string.
    The idea is to be able to test expansion strings that can be copied
    verbatim into a config file with different variable values.

    Any text that starts with a "." is a command that is handled by exixpand
    itself. These commands are explained in more detail below. Any other
    text is passed to 'exim -be' and the result is displayed.

COMMANDS
    .track <variable> [<value>]
        This causes exixpand to mark <variable> for interpolation in passed
        in strings. <variable> should not contain any spaces and should not
        start with a dollar sign (though it should when used in an expansion
        string). <variable> does not need to be the same as an internal exim
        expansion variable.

        <value> is optional. Leaving it blank will either set an empty
        variable or cause a previously set but untracked variable to be
        tracked (see .untrack below for details).

    .untrack <variable>
        .untrack causes exixpand to save the value for <variable> but stop
        interpolating it in strings. It can be reactivated using .track.
        This functionality is provided so that interpolation can be turned
        off without having to lose potentially complex or lengthy values.

    .unset <variable>
        .unset causes exixpand to completely forget about <variable>.

    .showvar [<variable>]
        .showvar shows the value of a tracked variable and whether it is
        currently active or not. If no <variable> is provided all variables
        are displayed.

    .exit, .quit, ^D
        Exit exixpand. Note that some bug seems to cause EOF not to be
        received properly in some perl versions. I've tried multiple
        versions of perl on Linux, Solaris, and Darwin, and 5.6.1
        consistantly fails to recognize EOF.

    .clear, ^C
        Reset internal state (empty multiline buffers).

EXAMPLES
    Test an ${if test against $sender_helo_name. Use of $GOODHELO and
    $BADHELO is done to demonstrate nested variable interpolation.

      expand> .track BADHELO host_name.domain.com
      expand> .track GOODHELO hostname.domain.com
      expand> .track sender_helo_name $GOODHELO
      expand> $sender_helo_name
      Evaluating: hostname.domain.com
      hostname.domain.com
      expand> ${if match{$sender_helo_name}{^.*_}{yes}fail}
      Evaluating: ${if match{hostname.domain.com}{^.*_}{yes}fail}
      Failed: "if" failed and "fail" requested
      expand> .track sender_helo_name $BADHELO
      expand> ${if match{$sender_helo_name}{^.*_}{yes}fail}
      Evaluating: ${if match{host_name.domain.com}{^.*_}{yes}fail}
      yes
      expand>

    This is a contrived example showing how you can use variable
    interpolation to make complicated expansions more simple. It uses small
    pieces to build up to a failry complicated expansion string which can be
    paste directly into a configuration file. (This specific example finds
    the number of seconds since midnight localtime.)

      expand> .track HOUR ${substr{11}{2}{$tod_log}}
      expand> $HOUR
      Evaluating: ${substr{11}{2}{$tod_log}}
      21
      expand> .track SECS_IN_HOUR ${eval:$HOUR*3600}
      expand> $SECS_IN_HOUR
      Evaluating: ${eval:${substr{11}{2}{$tod_log}}*3600}
      75600
      expand> .track BASE_SECS ${eval:3600*${eval:$tod_epoch/3600}}
      expand> $BASE_SECS
      Evaluating: ${eval:3600*${eval:$tod_epoch/3600}}
      1101438000
      expand> .track REMAINING_SECS ${eval:$tod_epoch-$BASE_SECS}
      expand> .showvar
      On? Name                 "Value"
        Y BASE_SECS            "${eval:3600*${eval:$tod_epoch/3600}}"
        Y HOUR                 "${substr{11}{2}{$tod_log}}"
        Y REMAINING_SECS       "${eval:$tod_epoch-$BASE_SECS}"
        Y SECS_IN_HOUR         "${eval:$HOUR*3600}"
      expand> ${eval:$SECS_IN_HOUR + $REMAINING_SECS}
      Evaluating: ${eval:${eval:${substr{11}{2}{$tod_log}}*3600} + ${eval:$tod_epoch-${eval:3600*${eval:$tod_epoch/3600}}}}
      77742
      expand>

