Subject: Re: '^M' in ascii files
To: Randy Arabie <rrarabie@arabie.org>
From: Jeff Rizzo <riz@boogers.sf.ca.us>
List: netbsd-help
Date: 02/09/2002 10:21:33
On Sat, Feb 09, 2002 at 11:13:17AM -0700, Randy Arabie wrote:
> Maybe this isn't a NetBSD thing....
> 
> I've got a gzipped tarball of files, all ascii stuff - *.php 
> and *.html.
> 
> When I 'tar xvfz' the files onto my linux box I have no problems.
> 
> However, when I 'tar xvfz' them onto my NetBSD box, many of the 
> files have '^M' appended to the end of each line.  The PHP engine 
> doesn't seem to like this.

These files must be from DOS/Windows.  UNIX-like OSes use LF as the newline
char; DOS uses CRLF.  (The CR is what you're seeing as ^M)

Probably linux is hiding this information from you... I'm sure the
characters are there.   Your simplest bet is to compile the "unix2dos"
package from pkgsrc;  (pkgsrc/converters/unix2dos) it has a simple-to-use
newline converter that goes both ways.
> 
> I thought it was a problem with the tarfile, but apparently it 
> isn't, since the carriage returns are not present in the files 
> on my linux box.
> 
> Is there some flag I need to pass tar to prevent this?
> 
> I know I can use strings, or some perl commands to clean these 
> files up, but it would be nicer to prevent it outright.

I'll admit to being somewhat surprised that PHP doesn't ignore the
extra CR, but no flag to tar (that I know of, anyway) will do the
conversion for you.

+j
-- 
Jeff Rizzo                                         http://boogers.sf.ca.us/~riz