delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/11/29/15:16:27

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_20,MISSING_HEADERS,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Date: Tue, 29 Nov 2011 14:15:58 -0600 (CST)
From: Tim McDaniel <tmcd AT panix DOT com>
cc: cygwin AT cygwin DOT com
Subject: RE: Shell script - is this expected behaviour?
In-Reply-To: <2BF01EB27B56CC478AD6E5A0A28931F2039D9646@A1DAL1SWPES19MB.ams.acs-inc.net>
Message-ID: <Pine.NEB.4.64.1111291410120.19989@panix3.panix.com>
References: <4ED4F78D DOT 303 AT redhat DOT com> <2BF01EB27B56CC478AD6E5A0A28931F2039D9646 AT A1DAL1SWPES19MB DOT ams DOT acs-inc DOT net>
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Nellis, Kenneth wrote:
> From: Eric Blake 
>> Never feed 'read' unterminated input.  Always end your text files
>> with a newline.
>
> When I can't control the contents of the input file, I pipe it
> through a filter program I wrote that adds a final newline where the
> last character of a stream is not a newline.

I don't have the time to experiment at the moment, but I'm pretty sure
that some of the standard tools append a line terminator if it's not
already on the last line of their input.  sed or awk or gawk, maybe?
Anyway, if you can stumble on such a program, it can save you having
to write and maintain and distribute a filter to all your
environments.

-- 
Tim McDaniel

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019