Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8461239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:49:31+00:00 2026-06-10T13:49:31+00:00

We have written a patch to replace ^M character supplied in the data file

  • 0

We have written a patch to replace ^M character supplied in the data file using a shell script;

sed 's/^M//g' source_file > target_file

but since we use subversion for source control of shell scripts and I am already specifying eol-style:native property; this ^M was replaced with new line when we take svn update on UNIX box and becomes

sed 's/
//g' source_file > target_file

As a better practice I recommended to replace this sed with dos2unix

dos2unix source_file > target_file

this got rid of ^M character but as a side effect it also replaced some meaningful data available in source_file which shouldn’t be converted.

So we want a way to get rid of ^M character from data file via a shell script which shouldn’t mention ^M character so that it can be ported Windows and Linux machine via subversion?

What is the best practice to get rid of such issues?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:49:33+00:00Added an answer on June 10, 2026 at 1:49 pm

    What you are seeing is someone editing a file in Windows — probably using Notepad — and committing the file into your Subversion repository. This adds on the line endings which screws up Makefiles and shell scripts.

    Fortunately, a good program editor (that is, not Notepad) can understand that line endings on various files are different, and can preserve and even convert line endings. This means that someone who is working on a Windows machine writing Unix shell scrips or Makefiles can, in theory eliminate the ^M you’re seeing. I urge developers to use IDEs like Eclipse that handle this issue, or at least use a program editor like VIM or Notepad++, but many still like using Notepad and screw everything up.

    What you have to do is give the developers the proper incentive to use the correct programming environment and stop messing up the files.

    Here are a couple of recommendations.

    1. You can use wire up high voltage lines to all of your developer’s chairs, and immediately give them a 1,000 volt shock whenever they use Notepad to edit a file.

    2. You can use Subversion’s built in mechanism to handle line ending on these files.

    Although the first approach is very tempting, I highly recommend the latter approach. Subversion has a property called svn:eol-style that can force automatically create the correct line ending upon a file. For example, if I set snv:eol-style to LF, the file will always have the correct line-feed line endings when it is committed or checked out. This way, you don’t have to do any post-processing to remove these line endings. Problem solved.

    The only issue is one of enforcement. When a developer creates a new file or edits an old one, they need to also set the property svn:eol-style to the correct value. There is an auto-prop mechanism in Subversion that can do this, but there is no way for you to make sure developers use it.

    I use a pre-commit hook that can refuse to allow files to be committed if they don’t have this property attached to them. You should be able to setup this hook script, so that only files that require this type of line ending (Unix scripts, Makefiles, etc.) while others that don’t aren’t affected (Java source code, XML, etc.).

    My pre-commit hook is fairly easy to setup and use. You use a control file to setup what you need. For example:

    [PROPERTY All Unix Scripts must have "svn:eol-style" set to "LF"]
    match = .\(sh|pl|py|ksh|csh)$
    property = svn:eol-style
    value = LF
    type = string
    
    [PROPERTY All Makefiles must have "svn:eol-style" set to "LF"]
    match = [Mm]akefile
    property svn:eol-style
    value = LF
    type = string
    

    This will ensure that the developers check in the files with the correct line endings in the first place, so you don’t have to run post-processing scripts on them. This can greatly simplify your deployment process and eliminate one of the largest causes of errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a bash script which installs a number of packages, however for
I have written a function that sorts a big scale of data. To test
I have written a raw binary image file into a buffer which is an
---Update 3: I have got the script to update the required data into the
I have written an xslt that reads some xml file names and does some
I have written List<Attachment> lstAttachment = new List<Attachment>(); //Check if any error file is
I have some code written in Ruby 1.9.2 patch level 136 and I'm have
I have a shell script that is created inside a php script (given full
I have written several services in Delphi now, but I want to add the
I have written a function which reads in an excel file and manipulates it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.