delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <fb34b27b0612050430u6d63aba9qfd127c2fa3da222b@mail.gmail.com> |
Date: | Tue, 5 Dec 2006 12:30:16 +0000 |
From: | "Mark Fisher" <mark DOT j DOT fisher AT gmail DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: bash CRLF problems (I have read the recent announcement) |
In-Reply-To: | <11218.1165279314@gemini.franz.com> |
MIME-Version: | 1.0 |
References: | <7794 DOT 1165273150 AT gemini DOT franz DOT com> <4574AE59 DOT 5080801 AT cygwin DOT com> <11218 DOT 1165279314 AT gemini DOT franz DOT com> |
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 |
On 12/5/06, Kevin Layer <layer at franz.com> wrote: > Larry Hall (Cygwin) <reply-to-list-only-lh at cygwin.com> wrote: > > >> > version=`cat foo1.out` > >> > ... > >> Time to adjust your expectations. ;-) Text mounts write CRNL as EOLs > >> for all files that are not explicitly opened as binary (or text for > >> that matter). Text mounts remove the CR from EOLs read from files that > >> are not explicitly opened as binary (or text). 'cat' explicitly opens > >> the file as binary. > > What is the portable way to get the contents of foo1.out into a > variable, getting proper translation of the end of lines? (If the > answer is use `d2u' that is not portable.) I thought I was safe by > using text mounts--I spent quite a while looking at the archives > before posting and thought I had covered all bases. > > Kevin > if you change the echo's to "echo -n" you don't get the ^M chars, as it surpresses the CR in the output. is this possible on the "real" scripts you talk about, or is the version generating script/app not changeable? $ cat foo1.sh echo -n 8010 > foo1.out $ cat foo2.sh sh foo1.sh version=`cat foo1.out` echo -n ${version}.bar > foo2.out cat -v foo2.out $ sh foo2.sh 8010.bar alternate solutions to using cat (which allow the \r\n in foo1.out) : version=`cut -f1 foo1.out` version=`awk '{print $1}' foo1.out` version=`sed -n '1p' foo1.out` cat is doing what it's supposed to, putting the whole file in the variable. don't use it. if you can't change the \r\n from your version file, use one of the alternatives. mark -- 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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |