Pregunta

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
} 
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top