All snippets have line endings converted to CR/LF
Problem
The HTML spec requires that form values are sent with line breaks as CRLF
pairs. We don't do any processing for snippets, but git implicitly does some for other files as they are backed by a repository.
This means that when getting a raw snippet, the line endings will be CRLF
pairs unless it was created through the API without those pairs.
For people wanting to use snippets to store scripts for executing on Posix-ish systems, this is a real pain.
Solution
- Convert all line endings to
LF
when requesting a raw snippet: https://gitlab.com/gitlab-org/gitlab-ce/issues/21240#note_21137076 - Add a param to keep the 'raw' raw line endings
😉 - Document this param briefly.
The expectation here is that Windows users aren't using snippets to execute code immediately.
Original description
I can't figure out a way to create a snippet without introducing windows-style line endings...
# Original curl - s https://gitlab.com/snippets/24662/raw | cat -A # Text copied into gitlab from FF50 curl - s https://gitlab.com/snippets/24665/raw | cat -A # Text copied into gitlab from Chromium 52 curl - s https://gitlab.com/snippets/24664/raw | cat -A
snippet of snippet:
#!/bin/bash^M$ declare -A ENVS^M$
Well that doesn't seem right....
Let's hash them real quick just to make sure they're all the same output:
for i in 2466{2,5,4}; do curl -s https://gitlab.com/snippets/24664/raw | md5sum; done 3e38541974206cf74d573bde5b0ae11e - 3e38541974206cf74d573bde5b0ae11e - 3e38541974206cf74d573bde5b0ae11e -
Alright, so, I can't conceive that this isn't a bug those line endings make this pretty much useless for Linux users and I'm sure many languages alike. The source is directly from my bash
konsole
terminal, and I also checked that withcat -A
for line-endings and they are normal Linux-style line-endings.Interim solution is to pipe things through
dos2unix
.Halp!