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 | wc -c
$ curl | wc -c

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.