line-endings

Convert line-endings for whole directory tree (Git)

风格不统一 提交于 2019-11-27 16:36:59
Following situation: I'm working on a Mac running OS X and recently joined a project whose members so far all use Windows. One of my first tasks was to set up the codebase in a Git repository, so I pulled the directory tree from FTP and tried to check it into the Git repo I had prepared locally. When trying to do this, all I got was this fatal: CRLF would be replaced by LF in blog/license.txt. Since this affects all files below the "blog" folder, I'm looking for a way to conveniently convert ALL files in the tree to Unix line-endings. Is there a tool that does that out of the box or do I get

git line endings - can't stash, reset and now can't rebase over spurious line endings commit

落花浮王杯 提交于 2019-11-27 12:03:13
问题 I have a repo I added a gitattributes to it and was working on it fine. I sync it via dropbox to another machine. When I opened it to the other machine a bunch of files suddenly appeared on the unstaged area as total diffs (all the file a huge diff which means line endings diff) - my crlf endings are basically .* text=auto and I am working on windows. I tried to stash the changes, reset the branch etc. At long last I decided to commit the files and then made some other commits I wanted to

How can I redirect PowerShell output when run from Task Scheduler?

限于喜欢 提交于 2019-11-27 11:56:00
问题 When running a simple PowerShell script from Task Scheduler, I would like to redirect the output to a file. There is a long thread about this very topic here, yet it's not clear if they reached the most appropriate solution in the end. I'm interested if anyone on Stack Overflow has also solved this problem, and how they did it? 回答1: Here is the command that worked for me. I didn't like the idea of redirecting the output in the script, since it would make it difficult to run manually.

What does Visual Studio mean by normalize inconsistent line endings?

强颜欢笑 提交于 2019-11-27 10:32:30
Visual Studio occasionally tells me: The line endings in the following files are not consistent. Do you want to normalize the line endings? It then gives me a drop down with different standards or something, such as Windows, Mac, Unix, and a couple of Unicode ones. What does this mean and what is going to happen if I click Yes ? What that usually means is that you have lines ending with something other than a carriage return/line feed pair. It often happens when you copy and paste from a web page into the code editor. Normalizing the line endings is just making sure that all of the line ending

How to read lines of a file in Ruby

一个人想着一个人 提交于 2019-11-27 10:03:59
I was trying to use the following code to read lines from a file. But when reading a file , the contents are all in one line: line_num=0 File.open('xxx.txt').each do |line| print "#{line_num += 1} #{line}" end But this file prints each line separately. I have to use stdin, like ruby my_prog.rb < file.txt , where I can't assume what the line-ending character is that the file uses. How can I handle it? Olivier L. I believe my answer covers your new concerns about handling any type of line endings since both "\r\n" and "\r" are converted to Linux standard "\n" before parsing the lines. To support

Carriage Return\Line feed in Java

試著忘記壹切 提交于 2019-11-27 10:01:31
问题 I have created a text file in Unix environment using Java code. For writing the text file I am using java.io.FileWriter and BufferedWriter . And for newline after each row I am using bw.newLine() method (where bw is object of BufferedWriter ). And I'm sending that text file by attaching in mail from Unix environment itself (automated that using Unix commands). My issue is, after I download the text file from mail in a Windows system, if I opened that text file the data is not properly aligned

Do any Java stream-input libraries preserve line ending characters?

无人久伴 提交于 2019-11-27 08:13:34
问题 I'd like to iterate through a text file one line at a time, operate on the contents, and stream the result to a separate file. Textbook case for BufferedReader.readLine() . But: I need to glue my lines together with newlines, and what if the original file didn't have the "right" newlines for my platform (DOS files on Linux or vice versa)? I guess I could read ahead a bit in the stream and see what kind of line endings I find, even though that's really hacky. But: suppose my input file doesn't

env: bash\\r: No such file or directory

走远了吗. 提交于 2019-11-27 06:52:29
I'm trying to install YouCompleteMe from here . When I execute: ./install.sh --clang-completer I get this error: env: bash\r: No such file or directory I don't know whats wrong with environment variables. Here's my bash path: which bash /bin/bash Do I need to change it to /usr/bash? If yes, then how should I do that? I tried changing ~/.bashrc file, but it didn't work. The error message suggests that the script you're invoking has embedded \r characters , which in turn suggests that it has Windows-style \r\n line endings instead of the \n -only line endings bash expects. As a quick fix , you

How to normalize working tree line endings in Git?

假如想象 提交于 2019-11-27 06:01:44
I have cloned a repository that had inconsistend line endings. I have added a .gitattributes that sets the text attribute for the files I want to normalize. Now when I commit changes I get the message: warning: CRLF will be replaced by LF in FILE. The file will have its original line endings in your working directory. How can I make git normalize my working copy of the file for me? Preferably I would like git to normalize the entire working tree. With Git client 2.16 and higher there is now a much simpler way to do this. Just use git add --renormalize . For those using v2.16 or better, you can

Historical reason behind different line ending at different platforms

谁说我不能喝 提交于 2019-11-27 04:35:55
Why did DOS/Windows and Mac decide to use \r\n and \r for line ending instead of \n? Was it just a result of trying to be "different" from Unix? And now that Mac OS X is Unix (-like), did Apple switch to \n from \r? DOS inherited CR-LF line endings (what you're calling \r\n, just making the ascii characters explicit) from CP/M. CP/M inherited it from the various DEC operating systems which influenced CP/M designer Gary Kildall. CR-LF was used so that the teletype machines would return the print head to the left margin (CR = carriage return), and then move to the next line (LF = line feed). The