Question

Is it right to use the following condition based on environment variables. Or there is better way?

Example:

# Both environment variables must exist
if {expr [eval {info exists env(VARIABLE_1)}] && [eval {info exists env(VARIABLE_2)}]} {
    # true: do something 
} else {
    # false: do something different
} 
Était-ce utile?

La solution

Using info alone should work:

# Both environment variables must exist
if {[info exists env(VARIABLE_1)] && [info exists env(VARIABLE_2)]} {
    # true: do something 
} else {
    # false: do something different
}

Since info returns a boolean, if handles it fine and you don't neet expr. The above works on my machine.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top