delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/09/19/10:47:06

X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: Read not honouring "-r"?
Date: Tue, 19 Sep 2006 10:46:46 -0400
Message-ID: <4C89134832705D4D85A6CD2EBF38AE0F7B0E10@PAUMAILU03.ags.agere.com>
From: "Williams, Gerald S \(Jerry\)" <gsw AT agere DOT com>
To: <cygwin AT cygwin DOT com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id k8JEl3RQ007547

I wrote:
> This seems to be particularly tied to ksh, and specifically
> when you use "<" to redirect a file. If you simply pipe the
> output of grep to the while loop, it works. Interestingly,
> sh, bash, and zsh all give the behavior you were expecting.

I couldn't resist trying it out on my Linux box, which runs
the same version of pdksh as my Cygwin install. Even more
interestingly, it works as you were expecting on Linux as
well. So this looks like a problem with the Cygwin port of
pdksh.

This simpler test case demonstrates it pretty clearly:

--test.sh--
dos2unix foo.txt
while read x; do echo "$x"; done < foo.txt
unix2dos foo.txt
while read x; do echo "$x"; done < foo.txt
--foo.txt--
1
2
3
----

Run under various shells:

$ sh test.sh    # zsh and bash yield same result
foo.txt: done.
1
2
3
foo.txt: done.
1
2
3
$ ksh test.sh   # this one fails for DOS endings
foo.txt: done.
1
2
3
foo.txt: done.
1


$ _

gsw

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


- Raw text -


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