X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_SORBS_WEB,RP_MATCHES_RCVD,SPF_HELO_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Oleksandr Gavenko Subject: Help me understand why 'eof' in canonical mode works strange in Expect script (and differ from Linux). Date: Sat, 17 Sep 2011 00:28:23 +0300 Lines: 48 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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