This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Help me understand why 'eof' in canonical mode works strange in Expect script (and differ from Linux).


This script work fine:

  $ cat eof.exp
#!/usr/bin/env expect

set stty_init "sane cooked -echo"

spawn sort
send \x04
expect eof
wait


But if I modify send expression to any like (so ^D is last char):


send booooo\x04

script infinitely await closing stdout by "sort", but
sort itself wait for closing stdin, which not happen.

Look like \x04 have 'eof' meaning in Expect pty only
in case then spawned process stdin empty.

For example this is not work ("sort" don't get 'eof'):

  spawn sort
  send bbb\raaa\r\0x04
  expect -re .+ { send_user $expect_out(buffer); exp_continue } eof { }

But this script work fine (but it is have drawback in 1 sec delay
before "sort" get 'eof'...):

  spawn sort
  send bbb\raaa\r
  set timeout 1
  expect {
    -re .+ { send_user $expect_out(buffer); exp_continue }
    timeout { send \x04; exp_continue }
    eof { }
  }

I try Linux and surprised that all my Expect scripts work fine.
Also note that sending another special character seems work in

send booooo\x03

pattern (on INTR  with "booo\x03" "sort" exit,
on QUIT with "booo\x1c" "sort" exit and 'sort.exe.stackdump' created).


-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]