Trimming final newline is not POSIX standards compliant
See original GitHub issueDoes this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.63.2
- OS Version: Ubuntu 20.04
Steps to Reproduce:
- Type anything in the editor and save it to a file
- Run
cat
to read the file
I am becoming increasingly annoyed by Visual Studio Code users because files are created without final newline.
This results in mangled shell prompt as shown above. In a sane world shell prompt starts on a new line.
Feel free to do this on Windows, but don’t bring this madness to Linux and Mac. You’re just wasting our time explaining how to turn off trimming and why trimming is bad.
In POSIX line ends with newline: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 and text file consists of 0 or more lines: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_403 Hence text file ends with a newline character
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:12 (5 by maintainers)
Top GitHub Comments
@alexdima what about POSIX macOS?
While changing the default may be unexpected for some users who are accustomed to working around the lack of newline at the end, they’re literally working around a bug. 😂
This kinda smells of the emacs-spacebar xkcd. https://xkcd.com/1172/
edit: I checked the Wikipedia article on POSIX.
This has become a bit of a recurring issue everywhere I’ve worked. People that use vim/emacs/sublime/IntelliJ end up producing POSIX compliant files, but the folks using VSCode don’t, and they have to be reminded every pull request. While developers should be comfortable configuring their tools, they should come with sane defaults.
Edit 2: on further reflection, anyone who needs to produce a file that doesn’t end in a newline knows they need to, but everyone should be creating files that end with a newline by default. This came after reading @laurivosandi’s comment below.
This default does not adhere to POSIX standard. People should not take extra steps to be standards compliant.