<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>posix &amp;mdash; sandeepk</title>
    <link>https://blogs.dgplug.org/sandeepk/tag:posix</link>
    <description></description>
    <pubDate>Thu, 30 Apr 2026 22:18:52 +0000</pubDate>
    <item>
      <title>No newline at the end of file ¯\(ツ)/¯</title>
      <link>https://blogs.dgplug.org/sandeepk/no-newline-at-the-end-of-file-_-tsu-_</link>
      <description>&lt;![CDATA[I came to see this warning a few days back when I was seeing the git diff of a file in reaction to this I open the file and hit enter at the last line to my surprise the warning remains still the same.&#xA;&#xA;What is a new line?&#xA;The new line is usually \n, aka (CR or CRLF) at the end of the file. It&#39;s helpful to identify the last byte of the file.&#xA;&#xA;Why it is good to have a new line at the end of the file?&#xA;&#xA;Quoting from here&#xA;&#xA;  A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character.&#xA;Since this is a &#34;shall&#34; clause, we must emit a diagnostic message for a violation of this rule.&#xA;&#xA;So, it turns out that, according to POSIX, every text file should end with a \n, or “newline” (not “a new line”) character. This acts as the eol, or the “end of line” character. It is a line “terminator”.&#xA;&#xA;It&#39;s helpful to identify the end of file. &#xA;&#xA;How to automatically add one with your favorite editor?&#xA;&#xA;In your favorite editor, you can add newline automatically like this.&#xA;&#xA;Emacs : Add (setq require-final-newline t) to your .emacs or .emacs.d/init.el file.&#xA;VS Code:  set &#34;files.insertFinalNewline&#34;: true&#xA;&#xA;#100DaysToOffload #POSIX #Git #NoNewLine&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>I came to see this warning a few days back when I was seeing the git diff of a file in reaction to this I open the file and hit enter at the last line to my surprise the warning remains still the same.</p>

<p><strong>What is a new line?</strong>
The new line is usually <em>\n</em>, aka (CR or CRLF) at the end of the file. It&#39;s helpful to identify the last byte of the file.</p>

<p><strong>Why it is good to have a new line at the end of the file?</strong></p>

<p>Quoting from <a href="https://gcc.gnu.org/legacy-ml/gcc/2003-11/msg01568.html" rel="nofollow">here</a></p>

<blockquote><p>A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character.
Since this is a “shall” clause, we must emit a diagnostic message for a violation of this rule.</p></blockquote>

<p>So, it turns out that, according to POSIX, every text file should end with a \n, or “newline” (not “a new line”) character. This acts as the <em>eol</em>, or the “end of line” character. It is a line “terminator”.</p>

<p>It&#39;s helpful to identify the end of file.</p>

<p><strong>How to automatically add one with your favorite editor?</strong></p>

<p>In your favorite editor, you can add newline automatically like this.</p>
<ul><li><strong>Emacs</strong> : Add (setq require-final-newline t) to your .emacs or .emacs.d/init.el file.</li>
<li><strong>VS Code</strong>:  set “files.insertFinalNewline”: true</li></ul>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a> <a href="/sandeepk/tag:POSIX" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">POSIX</span></a> <a href="/sandeepk/tag:Git" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Git</span></a> <a href="/sandeepk/tag:NoNewLine" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">NoNewLine</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/no-newline-at-the-end-of-file-_-tsu-_</guid>
      <pubDate>Sun, 16 May 2021 13:52:00 +0000</pubDate>
    </item>
  </channel>
</rss>