git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/5] Abide by our own rules regarding line endings

From
Junio C Hamano <gitster@pobox.com>
Date
May 4, 2017, 15:04 UTC
Message-ID
<xmqq60hgacjp.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<alpine.DEB.2.21.1.1705041129170.4905@virtualbox>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 6 quoted lines
> Well, a couple of comments about your comment:
>
> - we say "shell scripts", but we're sloppy there: they are "Unix shell
>   scripts", as they are executed by Unix shells. As such, it is pretty
>   obvious that they favor Unix line endings, right? And that they do not
>   really handle anything else well, right?
Not really.  I would expect that
	cat A B C

with CRLF line endings (i.e. "cat A B C<CR><LF>") on platforms whose eol convention is LF to barf due to the missing file whose name is "C<CR>", while on platforms whose eol convention is CRLF, I do expect the contents of file C comes at the end of the output.

> - You try to say that it is not okay for shell scripts to be checked
>   out as LF-only when the platform convention for *text* files is CR/LF,
>   right? 

I didn't try to and I didn't say that, I hope. I think it is not OK for shell scripts to be checked out with <CR><LF> when the platform convention for text is <LF>, though. It may be possible for an implementation on CRLF platform to tolerate missing <CR> (i.e. a file in LF convention--instead of treating a lone <LF> as a non-eol but just a regular "funny" byte, treat it as a normal eol), but that would be a quality-of-implementation thing. So when the platform convention for text files is <CR><LF>, I would have thought that it was more natural to check out shell scripts as such.

However, I did not think things through when I said "I am not sure if it is OK for shell scripts not to honor the platform convention, though." In a sense, the "cat A B C" example does not have to worry about the platform convention issue very much. In real scripts, we have things like a string literal that spans lines (i.e. do we have a LF, or a CRLF pair, in between these two lines?) and here documents (ditto). To handle these "correctly" while treating shell scripts mere "text" files, a shell implementation on CRLF platform has to accept CRLF, pretend as if it saw only LF, do all the processing as if the eol convention were LF, and convert LF in the output from the script to CRLF. I think that is _too_ much to ask for an implementation, and such an attempt would get corner cases wrong. IOW, I was not sure if it is OK for scripts not to honor the platorm convention when I wrote the message you are responding to, but I think it probably is not just OK but is the simplest/cleanest for shell implementations not to honor the platform convention and instead pretend that they always live in LF-only world.

And all of the above ultimately does not matter. If the shell you have on Windows cannot take CRLF files, then our shell script must be checked out as LF files even on Windows. My "I am not sure" was mostly from not knowing how ingrained that "cannot take CRLF files" was (i.e. I didn't know if there may be some knobs similar to core.crlf we have that you can toggle for your shell to honor the platform convention).

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 11 of 39 in “Abide by our own rules regarding line endings”
  1. 0/5 Abide by our own rules regarding line endingsJohannes Schindelin, May 2, 2017
  2. 2/5 git-new-workdir: mark script as LF-onlyJohannes Schindelin, May 2, 2017
  3. 1/5 Fix build with core.autocrlf=trueJohannes Schindelin, May 2, 2017
  4. 3/5 completion: mark bash script as LF-onlyJohannes Schindelin, May 2, 2017
  5. 5/5 t4051: mark supporting files as requiring LF-only line endingsJohannes Schindelin, May 2, 2017
  6. 4/5 Fix the remaining tests that failed with core.autocrlf=trueJohannes Schindelin, May 2, 2017
  7. Jonathan NiederMay 2, 2017
  8. Johannes SchindelinMay 3, 2017
  9. Junio C HamanoMay 4, 2017
  10. Johannes SchindelinMay 4, 2017
  11. Junio C HamanoMay 4, 2017
  12. Johannes SchindelinMay 4, 2017
  13. Junio C HamanoMay 7, 2017
  14. Johannes SchindelinMay 8, 2017
  15. 0/7 Abide by our own rules regarding line endingsJohannes Schindelin, May 4, 2017
  16. 1/7 Fix build with core.autocrlf=trueJohannes Schindelin, May 4, 2017
  17. Junio C HamanoMay 8, 2017
  18. 2/7 git-new-workdir: mark script as LF-onlyJohannes Schindelin, May 4, 2017
  19. Junio C HamanoMay 8, 2017
  20. 4/7 t3901: move supporting files into t/t3901/Johannes Schindelin, May 4, 2017
  21. Junio C HamanoMay 8, 2017
  22. 3/7 completion: mark bash script as LF-onlyJohannes Schindelin, May 4, 2017
  23. 5/7 t4003, t4005, t4007 & t4008: handle CR/LF in t/README & t/diff-lib/READMEJohannes Schindelin, May 4, 2017
  24. Junio C HamanoMay 8, 2017
  25. 6/7 Fix the remaining tests that failed with core.autocrlf=trueJohannes Schindelin, May 4, 2017
  26. Junio C HamanoMay 8, 2017
  27. 7/7 t4051: mark supporting files as requiring LF-only line endingsJohannes Schindelin, May 4, 2017
  28. Junio C HamanoMay 8, 2017
  29. Johannes SchindelinMay 9, 2017
  30. 0/6 Abide by our own rules regarding line endingsJohannes Schindelin, May 9, 2017
  31. 1/6 Fix build with core.autocrlf=trueJohannes Schindelin, May 9, 2017
  32. Jonathan NiederMay 22, 2017
  33. Junio C HamanoMay 23, 2017
  34. Johannes SchindelinMay 23, 2017
  35. 2/6 git-new-workdir: mark script as LF-onlyJohannes Schindelin, May 9, 2017
  36. 3/6 completion: mark bash script as LF-onlyJohannes Schindelin, May 9, 2017
  37. 4/6 t3901: move supporting files into t/t3901/Johannes Schindelin, May 9, 2017
  38. 5/6 Fix the remaining tests that failed with core.autocrlf=trueJohannes Schindelin, May 9, 2017
  39. 6/6 t4051: mark supporting files as requiring LF-only line endingsJohannes Schindelin, May 9, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.