Home > database >  How to compare two ints in expect shell?
How to compare two ints in expect shell?

Time:07-23

I want subtract a number in expect shell until it equals 0, then close this shell, such as :

#!/usr/bin/expect
set round [lindex $argv 0];
incr round -1
if round <= 0 close  // ??how to write this sentence?

CodePudding user response:

Your last line would be:

if {$round <= 0} exit

BUT I think you actually want to decrement the counter repeatedly, for which you would need a loop:

while {$round > 0} {
    incr round -1
}
  • Related