trailing newline / eol with Gist editor

I’ve noticed that when I create Gist files with the Gist editor, it does not add a trailing newline \n for the last line (which is a Unix standard).

You can confirm by downloading the raw gist file with curl, then doing cat on the downloaded file. You will see that the cat output will run on with the next command prompt without a newline.

You could add an extra line at the bottom of the file, but that will result in \n\n, which isn’t right either.

Is there a way to get the correct trailing newline with the Gist editor? (Does the Github editor do the same thing?)

Thanks for reaching out.

I can’t replicate what you’re describing. I created a gist containing two files with the same content other than pressing Enter at the end. Then I executed the following commands:

$ curl https://gist.githubusercontent.com/lee-dohm/06d4396e04fba40005ed495b6ad3ea2e/raw/2cd8a6db06c8924e5cd0c25fc46c38f256c85f09/no-newline.txt | wc -c
       3
$ curl https://gist.githubusercontent.com/lee-dohm/06d4396e04fba40005ed495b6ad3ea2e/raw/2cd8a6db06c8924e5cd0c25fc46c38f256c85f09/with-newline.txt | wc -c
       4

There is only a difference of one character, not two as would be the case if things acted as you describe. Can you be more specific as to how exactly you reproduced the problem?

Let us know.