문제

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
} 
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top