At this link I've read the for loop management for except https://tcl.tk/man/tcl8.6/TclCmd/for.htm
If you call expect and paste the code in in you get the correct behavoir :
@gigi:~$ expect
expect1.1> for {set x 0} {$x<10} {incr x} {
puts "x is $x"
}+> +>
x is 0
x is 1
x is 2
x is 3
x is 4
x is 5
x is 6
x is 7
x is 8
x is 9
expect1.2>
Instead if you pass it from bash script it goes to error:
^@gigi:~expect -d << EOD
> for {set x 0} {$x<10} {incr x} {
> puts "x is $x"
> }
> EOD
expect version 5.45.4
argv[0] = expect argv[1] = -d
set argc 0
set argv0 "expect"
set argv ""
executing commands from command file
missing operand at _@_
in expression "_@_<10"
(parsing expression "<10")
invoked from within
"for {set x 0} {<10} {incr x} {
puts "x is "
Why this example work different?