In some cases, you might need to manipulate the values returned by variables. You can use two substitution formats to handle these situations.
You can use a special substitution format when a variable could return an empty value. The format consists of three arguments in brackets. The first argument is in the form $[? variable]. The second argument determines what to return if variable has a nonempty value. The third argument determines what to return if variable has an empty value.
For example, consider the following expression:
$[? MODULE] [${PS}${MODULE}] []If the MODULE variable has a value, the expression returns a path separator, represented by the PS, and the module name. If the value of MODULE is empty or there is no MODULE variable defined for the profile, the expression returns an empty string without the extraneous path separator.
In some cases, such as when the version control system uses a different path separator than the operating system, it is useful to substitute one character returned by a variable with another character. You can create this substitution by calling the variable, followed by an underscore (_), the character you want to be replaced, and the character you want to substitute.
For example, you can use the following expression in a command:
${PATH_\/}Any backward slashes (\) that are in the value of the profile's PATH variable are replaced with forward slashes (/) when the expression is resolved upon running the command.
See also | |
---|---|
Variables in VCS Commands Creating a New Variable Runtime Variables Variable Syntax and Usage Creating a Custom VCS Profile |