Typically, I can use the expect
mechanic of expect
followed by send
. In the case of git
's interactive shell, however, this does not work and I must use puts
.
Is there some trick to restore the normal usage of the shell? Or could this be a cross-platform issue on Mac that would not exist were I on a linux machine?
#!/usr/bin/expect# get the expected countset ct [exec git status | grep -e {deleted by us:} | awk {END{print NR}}]puts "expect count = $ct"spawn bashsend "git mergetool\r"for {set i 0} {$i < $ct} {incr i} { expect -re "^.*local.: (.*)$" set choice $expect_out(1,string) set choice_letter [string index $choice 0] expect -re ".*Use.*\?.*" { puts "$choice_letter\r" } # here I have to use puts, weird}
Is this some bizarre mac thing, or have I learned normal, regular expect behavior and am properly using puts
instead of send
in this automatic script?