Skip to main content

1E 23.7 (SaaS)

EXPAND

Function

EXPAND

Action

Expands environment variables in a string

Parameters

(string) A string containing environment variables in the form %variable% for Windows, and $variable for non-Windows operating systems.

Return values

(string) The string with the environment variables replaced, where possible.

Example

Returns "xcopy C:\Windows\MEMORY.DMP \\share\crashdumps":

SELECT "xcopy " || EXPAND("%windir%\\MEMORY.DMP") || " \\\\share\\crashdumps" AS CommandLine;

This Linux example shows how a variable that does not exist is returned unchanged, returning the "$IDONOTEXIST does not exist" as the value of ExpandedText:

SELECT EXPAND("$IDONOTEXIST does not exist") AS ExpandedText;

Notes

Replacements will only occur for environment variables. If an environment variable does not exist, Expand will not modify that portion of the string. (This is different from certain shells such as Bash which usually expand an undefined variable to an empty string.)

If an empty string is supplied as the parameter, an empty string will be returned. If a NULL is supplied as the parameter, a NULL will be returned.

On non-Windows, daemons (including the Tachyon Agent) have a limited set of environment variables compared with user accounts.