SYNTAX

    var [options] <variable> <operation> [<argument>]


OPTIONS

-h (--help) bool

Display help.


ARGUMENTS

<variable>

The environment variable to be operated on. [string]

<operation>

The operation to be performed.

defined

Test if the specified environment variable is defined.

not-defined

Opposite of defined.

==

Tests if the specified environment variable is an exact string match for the supplied argument.

!=

Opposite of ==.

add

Assume that the specified environment variable holds an integer, and adds the value given by the argument to it. If the variable isn't defined or doesn't contain a decimal integer, it is assumed to have value zero.

subtract

Subtracts the given value from the environment variable. Semantics as per add.

multiply

Multiply the specified environment variable by the given value.

startswith

Tests if the specified environment variable starts with the supplied argument.

endswith

Tests if the specified environment variable ends with the supplied argument.

lessthan

Tests if the specified environment variable is numerically less than the supplied argument.

lt

Abbreviation for lessthan.

lessorequal

Tests if the specified environment variable is numerically less than or equal to the supplied argument.

le

Abbreviation for lessorequal.

greaterthan

Tests if the specified environment variable is numerically greater than the supplied argument.

gt

Abbreviation for greaterthan.

greaterorequal

Tests if the specified environment variable is numerically greater than or equal to the supplied argument.

ge

Abbreviation for greaterorequal.

[<argument>]

The argument to the operation. [string]


DESCRIPTION

Perform an operation involving environment variables.

This command returns zero (KErrNone) in the success case, and a non-zero positive code otherwise. Usage:

    var SOMETHING defined # Doesn't cause an error, returns '1'
    var SOMETHING defined && echo Defined # Nothing is echoed
    export SOMETHING 1
    var SOMETHING defined && echo Defined # "Defined" will be printed
    var SOMETHING == 1 && echo "Equal" # "Equal" will be printed
    var SOMETHING add 3 && echo "$SOMETHING" # $SOMETHING now has value "4"
    var SOMETHING lt 10 && echo "Less than 10" # "Less than 10" will be printed

== and != are text comparisons not numerical, and all environment variables are strings, so the following will not work:

    export VAL 16
    var VAL == 0x10 && echo Equal # Error! "16" does not equal "0x10"

The numerical comparison operators are named lessthan, greaterthan etc (with abbreviations like lt, le) because the < and > operators are reserved for stdio redirection.


COPYRIGHT

Copyright (c) 2006-2011 Accenture. All rights reserved.