Hacker News new | past | comments | ask | show | jobs | submit login

Is this articles note about needing to place a newline at the end of a standards compliant C program actually accurate?

When I write out a file containing "aaaaa" with nano (to avoid any unusual tricks vim might use), and then hexdump it, I get "6161 6161 0a61". In other words, nano slapped on an ending newline when I saved. It is my impression that everything does this.




It has long been unix convention that every line of text is followed by a terminating character. It used to be that many command-line tools relied on this, I suspect most tools are more forgiving nowadays. Nearly all linux/unix text editors perform little normalizations to be as compatible as possible. I bet if you opened a file in vim's binary editing mode (vim -b) you could write it without the final line ending (does nano also have a binary mode? might be worth trying).

Edit: Apparently nano has a -L option that skips the last-line normalization.


If you open it in Emacs, by default (at least it did when I toyed with 21) it leaves the trailing newline off.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: