Delivered-To: listarch-cygwin AT sourceware DOT cygnus DOT com Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Delivered-To: uwin-users AT research DOT att DOT com Date: Thu, 11 Feb 1999 16:08:44 -0500 (EST) From: Christopher Vickery X-Sender: vickery AT babbage To: Bruce Lilly Cc: Luke Kendall , "uwin-users AT research DOT att DOT com" Subject: Re: sh read mis-handling CR/LF? In-Reply-To: <36C33BA2.9143FE90@erols.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-uwin-users AT research DOT att DOT com > ---------- > From: Christopher Vickery > Sent: 1999年2月12日 6:08:44 > To: Bruce Lilly > Cc: Luke Kendall; uwin-users AT research DOT att DOT com > Subject: Re: sh read mis-handling CR/LF? > Auto forwarded by a Rule > On Thu, 11 Feb 1999, Bruce Lilly wrote: > Luke Kendall wrote: > > > > This is under Windows NT 4.0 sp4, U/WIN 2.0b1. > > > > Surely the shell's read function should not be opening files > > in binary mode? Surely it should be stripping the CR and LF from > > the end of the input line? > > > > I think the stuff below speaks for itself. Please let me know > > if I'm confused here. > > > > ---- test-here script ----- > > #!/bin/sh > > cat <<-'EOF' > test-input > > test-1 > > EOF > > read f rest < test-input > > if [ "$f" = "test-1" ] > > then > > echo "Read matches" > > else > > echo "Read mis-match" > > fi > > > > echo "od of input file:" > > od -c test-input > > echo "od of input line re-echoed:" > > echo "$f$rest" | od -c > > ---------- end ----------- > > OK (you asked for it!) you're confused. You need to eliminate the whitespace > before the "test-1" and "EOF" lines for starters. No, presumably they were tabs that got lost in conversion to email. That part of the code works fine as long as the leading whitespace is a tab; that's what the '-' in "cat <<-" means. > > Having made that correction and run the script, I get the following > output here (also NT 4.0 SP4 and U/WIN 2.0Beta1, with msvcrt.dll > version 6.00.8337.0): > > Read matches od of input file: 0000000 t e s t - 1 ¥n > 0000007 od of input line re-echoed: 0000000 t e s t - 1 > ¥n 0000007 > > > Note that I/O results may vary with the version of msvcrt.dll on your > system, as I posted a week and a half ago (titled "¥015 before > newline"). I don't understand what msvcrt.dll has to do with this because, as I posted yesterday, the issue is what is being written to the test file, which depends on whether the lines in the script terminate with ¥n or ¥r¥n. Whatever terminates the lines in the here document is what gets written to the test file. Then it is a matter of whether you override read's standard line delimiter of ¥n using the -d option or not. But there is no way to consume ¥r¥n with a single read so far as I know. Chris Vickery ____________________________________________________________ If you need help unsubscribing or using this list in general, send mail to owner-uwin-users AT research DOT att DOT com To unsubscribe from this list, please send the following two-line message to majordomo AT research DOT att DOT com, in which your_email_address should be replaced by the address you used when you subscribed to the list: unsubscribe uwin-users your_email_address end -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com