Index of Section 1 Manual Pages

Interix / SUAeval.1Interix / SUA

eval(1)                                                         eval(1)

  eval

  NAME

    eval - parse and execute (evaluate) a command string

  SYNOPSIS

    eval string ...

  DESCRIPTION

    The eval(1) command is a special shell built-in command that concatenates
    its arguments, separating them with spaces, and then parses the resulting
    command line as if it were a new command. The eval(1) command is useful
    for making a second pass over a command string if it contains shell
    variables that, in turn, contain:

    *     Other shell variables
    *     Aliases
    *     Input/output (I/O) redirectors

    The eval(1) command is particularly useful in shell scripts that must
    build up a command line that is then evaluated and executed.

    Because a command passed to eval(1) goes through shell variable and
    redirection expansion twice, you must use care in trying to pass literal
    metacharacters.

  DIAGNOSTICS

    The eval(1) command gives the following diagnostics:

    0
        There were no arguments, or the arguments you specified were empty
        strings.

    Otherwise, eval(1) returns the exit status of the command that eval(1)
    executes.

  EXAMPLES

    The following shell script shows how to include a redirection character in
    a variable:

    while getopts f:t: opt
    do
         case "$opt" in
         'f') FILE="> $OPTARG"
              ;;
         't') TEE="| tee $OPTARG"
              ;;
         esac
    done
    shift $OPTIND-1
    eval awk -f script.awk $@ $TEE $FILE

    Without eval(1), the command line would not work if any options were
    given. Because redirection is resolved before the variables are expanded,
    the FILE argument (for example) would be expanded to a file named ">
    $OPTARG" (space included), which doesn't exist.

    If the command line contains redirection characters that are not in a
    shell variable, you may need to quote it.

  SEE ALSO

    ksh(1)

    sh(1)


Interix / SUAHosted at SUA Community for Interix, SUA and SFUInterix / SUA