X-Spam-Check-By: sourceware.org Message-ID: Date: Tue, 5 Dec 2006 12:30:16 +0000 From: "Mark Fisher" 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 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 wrote: > Larry Hall (Cygwin) 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/