You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/02/07 15:21:22 UTC
[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on issue #56:
Ensure all source code end with one and only one newline
xiaoxiang781216 commented on issue #56: Ensure all source code end with one and only one newline
URL: https://github.com/apache/incubator-nuttx-apps/pull/56#issuecomment-583449362
> "is this safe on all types of files?" It is inappropriate on the .txt file that needs the newline for visual spacing.
>
Ok, I will remove the test file from PR.
> Other source files will depend on if there is 0 or 1 newlines at the end. Looking at the diffs, I cannot tell if there is 0 or 1 newlines at the end now.
>
The command can ensure this:
git ls-files -z | while IFS= read -rd '' f; do tail -c1 < "$f" | read -r _ || echo >> "$f"; done
Here has the detailed explanation for each step:
https://unix.stackexchange.com/questions/31947/how-to-add-a-newline-to-the-end-of-a-file
Actually, it's good thing to ensure one and only one newline at the end of file for consistency and avoid git complain "No newline at end of file":

> I would think that most apps should work with a single newline. Many applications are even tolerant of missing newlines at the end altogether. kconfig-frontends is not. Kconfig files with no newline at the end causes errors.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services