From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13728 invoked from network); 6 Apr 2009 08:59:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Apr 2009 08:59:19 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 33937 invoked from network); 6 Apr 2009 08:59:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Apr 2009 08:59:14 -0000 Received: (qmail 2461 invoked by alias); 6 Apr 2009 08:59:07 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26810 Received: (qmail 2450 invoked from network); 6 Apr 2009 08:59:07 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 6 Apr 2009 08:59:07 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [85.115.60.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 6D68882D4B6A for ; Mon, 6 Apr 2009 10:59:04 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly03d.srv.mailcontrol.com (MailControl) with ESMTP id n368x2gH024484 for ; Mon, 6 Apr 2009 09:59:02 +0100 Received: from news01 ([10.99.50.25]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 6 Apr 2009 09:59:01 +0100 Date: Mon, 6 Apr 2009 09:59:01 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: tcp_read -d and newlines Message-ID: <20090406095901.297232b0@news01> In-Reply-To: <20090405231036.GA13802@scru.org> References: <20090405231036.GA13802@scru.org> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 06 Apr 2009 08:59:01.0711 (UTC) FILETIME=[EE0EF5F0:01C9B695] X-Scanned-By: MailControl A_08_51_00 (www.mailcontrol.com) on 10.68.0.113 X-Virus-Scanned: ClamAV 0.92.1/9206/Sun Apr 5 20:23:11 2009 on bifrost X-Virus-Status: Clean On Sun, 5 Apr 2009 23:10:36 +0000 Clint Adams wrote: > When tcp_read -d'ing a socket that doesn't end in a newline, the last > "line" gets discarded, I think, because read returns an error on that > line. I've had problems with this, too, in the past, although I think my problem was chunks of input (not necessarily ending in EOF) that didn't have newlines. I could find an easy way of handling this. It sounds like your problem is when there is an EOF. > What can be done? One possible but slightly clumsy mechanism is to introduce a flag, say -D, that allows an incomplete line but returns something different if there's no delimiter (e.g. it sets REPLY2 to the delimiter actually read which may be empty, and I suppose we could allow it to be the EOF character too). It's clumsy because if you want to fix my case you have to poll for input, and we've found in the past that doing this correctly on terminals can be a black art (terminals aren't the problem here but it's up to us to disguise the type of input as much as possible since it's not fair to tell shell users it's all termios' fault). If we plan on getting an EOF it's relatively straightforward. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070