Cygwin EOL Windows

0

I am trying to remember how to configure Cygwin to use windows EOL instead of Unix EOL. I haven't had to do this in years and I just bought a new laptop.

NOTE: Bear with me as I describe the issue. I do not desire responses directing me to use bash shell or perl or anything other than solving the described issue. I know it is possible; I have done so since Win2k. And my now-dead Vista machine worked this way for 10 years. If it hadn't croaked, I would have the bookmark :( My Win 7 laptop at my former employer worked this way. I remember some step of setting the EOL in the default bash shell; but cannot find any site referencing anything near the issue described below.

Steps to reproduce: Picking any arbitrary search string with EOL, grep will not find it. E.g., if have sample.txt file:

This is
my sample file
with some random
text
in it.
I could go on with this
but it is
redundant
  1. Open a Windows Command Prompt
  2. execute "grep -i is$ sample.txt"
  3. No results are returned.

Now, execute

  1. "dos2unix sample.txt"
  2. execute "grep -i is$ sample.txt"
  3. returns the following, as expected
This is
I could go on with this
but it is

Now...

It is not feasible for me to convert all files every time I want to grep. I want to figure out what I did in the past to change grep to look for Windows EOL and not convert the files to Unix EOL.

I simply cannot remember the steps to run in the default bash shell, or whatever, to effect it. I have searched exhaustively and cannot figure the correct terms to bring up a solution. I am only finding solutions for people who use Ubuntu on Windows or people who use bash shell command instead of Windows Command or other irrelevant solutions.

I did try to add the solution prescribed on a few sites of adding

   export SHELLOPTS
   set -o igncr
to the Cygwin/home/user/.bash_profile (where user is my Win user name) and it did not work--even when running the command within a bash shell.

I seem to remember that when running Cygwin solely from a Windows prompt, as I do, there is some default shell that you have to open in bash and type some stuff to make Cygwin recognize the Windows EOL. I cannot find that solution.

I have also tried changing my grep command to use POSIX and -E and other prescribed solutions; none worked and I never had to do that in the past. I have always used the commands above with no issue (after applying the fix).

Finally, I have also uninstalled and re-installed Cygwin, to no avail (of course). I saw quite a few sites that indicated that the EOL char is set in the installation; but I am neither prompted for it nor see any screen that indicates a flag for it. And I do not remember this in any Cygwin install dialog from the past. I am installing the 64-bit Windows version found at https://www.cygwin.com/install.html. I use 64-bit Windows 10 1903.

I apologize for the length of this post; but I wanted to be precise and clear on the issue, the steps I have tried, and what I desire.

Thank you in advance for your response.

Ivan Ho

Posted 2019-08-28T07:11:29.333

Reputation: 3

I don’t think this is a matter of configuration (in general). It’s simply built into most Linux/Unix software that the line ending is just a LF. You’d have to patch everything to change that. – Daniel B – 2019-08-28T07:14:28.367

Not sure you understood. I am using Windows, not Linux/Unix. And, as stated more than once, this has worked for me in the past (on Win2k, Vista, and Win7). – Ivan Ho – 2019-08-28T07:55:01.460

No, you are not using Windows. You are using Cygwin, which runs unmodified (though compiled for Cygwin) Linux/Unix software. – Daniel B – 2019-08-28T11:06:56.723

Do you know how to change the default shell to recognize Windows EOL? – Ivan Ho – 2019-08-28T18:34:31.240

Answers

0

Ok. I give up. I can only surmise that I was using an older Cygwin distro that ignored the \r. I believe I remember something like that from > 10yr ago. I used to just port my customized distro around with me, rather than have to re-install the glut every time I changed machines when I was a contractor.

So, rather than change all of my scripts to use Windows findstr or sed the streams to remove the \r, I will just run dos2unix.

I did not want to resort to this because I don't own these files. So, I have to make a copy, perform the dos2unix and grep the copies. Fortunately, I do not have to do this often.

For all of my SVN and Git repos, I set the filetype to Unix EOL in the config. It is only this particular NAS repo that was causing me issues.

@Daniel B--Thanks for your responses.

If I do figure this out (or can somehow glean it from the Vista drive), I will post the solution here.

Ivan Ho

Posted 2019-08-28T07:11:29.333

Reputation: 3