5 ms·
This isn't completely related to Windows command line but I thought I would post it out here. I was trying to run a Bash script from a Git repo mounted in a Do
by jasonjei 10y ago
This isn't completely related to Windows command line but I thought I would post it out here.
I was trying to run a Bash script from a Git repo mounted in a Docker container. When running the Bash script, I kept getting all kinds of errors. I ran the exact same script in the same Docker container on a different Linux computer that had cloned the repo. It turns out the \r Windows line endings (which I later normalized in Git settings) caused my script to barf.
- chipperyman573 10y agoYou can also normalize them using the dos2unix package, which is available on most distros.
- bluejekyll 10y agoHave the line ending wars ended yet? Apple is finally Unix \n, but most internet protocols are \r\n as are Windows. Though honestly, Windows just doesn't even matter any more to me, I haven't needed to touch an MS product in years...
- stephengillie 10y agoGit for Windows asks during installation if you want to replace your Windows line endings with Unix-style. You can have it replace LF with CRLF on checkout and revert on commit, or you can just have it do the revert (swap CRLF with LF) on commit and not do the first replace. Or you can just leave everything as-is. Interestingly, when manually making a multi-line string in Powershell, only the LF character ( `n ) is needed to make a new line. Using CRLF ( 'r'n ) gives identical behavior in most strings.
- userbinator 10y agohttps://en.wikipedia.org/wiki/Newline#History https://en.wikipedia.org/wiki/Newline#History \r\n, CR+LF historically speaking was the first, but \n, LF became dominant because of Unix.
- Jaruzel 10y agoIf you break it down and view them as terminal codes (or as the spec was designed, on a teletype), CR+LF is correct, and LF is not. However, the inconsistencies of this over time have become really annoying. My long term pet peeve is in VB.NET when I have to do this: ' This works - using the VB6 interop Split(StringName,vbCrLf) ' This doesn't work - using the native .NET function ' because .split is only expecting a Char, and not a String) StringName.Split(vbCrLf) Really, really annoying.
- Retra 10y agoWhy would you want strings to be formatted using terminal codes? It's just textual data. It has nothing to do with terminals, other then the fact that terminals need to handle text. I see little reason that text should have to handle terminals. With that said, CR+LF is just inefficient, since doing both of those tasks together is what is overwhelmingly desired for a newline.
- bluejekyll 10y ago\r\n has always seemed redundant, regardless of the standards. I get using \r without \n for fun rewriting of a current line of text on a terminal. But has anyone (in recent years) honestly want a new line, without a carriage return? And why did all the internet protocols settle on this? It's an extra 8bits that are unnecessary.
- loeg 10y agoOr just `sed -e 's|\r||'`.
- xorcist 10y agoIf you just want to delete a character there's no need for sed. Just do: tr -d '\r'