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

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RP_MATCHES_RCVD,SPF_HELO_PASS
X-Spam-Check-By: sourceware.org
Mail-Followup-To: cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
From: Gary <listgj-cygwin AT yahoo DOT co DOT uk>
Subject: Shell script - is this expected behaviour?
Date: Tue, 29 Nov 2011 10:00:46 +0100
Lines: 28
Message-ID: <jb26vu$5tc$1@dough.gmane.org>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (cygwin)
X-No-Archive: Yes
Mail-Copies-To: never
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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

If I have a shell script which reads a file which does not have an end
of line character at the end if it's only line, it does not read
anything.

For example:
,----
| #!/bin/sh
| 
| fileName="test.xml"
| retVal="Z"
| 
| exec 10<&0
| exec < $fileName
| while read configLine
| do
|     retVal="A"
| done
| exec 0<&10 10<&-
| 
| echo $retVal
| 
| exit 0
`----

If it's expected behaviour, what's the workaround?

-- 
Gary        Please do NOT send me 'courtesy' replies off-list.


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