Clean up: Difference between revisions

From Nasqueron Agora
No edit summary
(→‎Style: UTF-U BOM, from freebsd-tips fortune)
 
Line 5: Line 5:
You can add them with <code>echo</code>.
You can add them with <code>echo</code>.


<source source="console">
<syntaxhighlight lang="console">
$ git ls-files | while read f; do tail -n1 $f | read -r _ || echo >> $f; done
$ git ls-files | while read f; do tail -n1 $f | read -r _ || echo >> $f; done
</source>
</syntaxhighlight>


=== UNIX lines ===
=== UNIX lines ===
<source source="console">
<syntaxhighlight lang="console">
$ dos2unix
$ dos2unix
</source>
</syntaxhighlight>


=== Encoding ===
=== Encoding ===
<source source="console">
<syntaxhighlight lang="console">
$ iconv -f iso-8859-15 -t utf-8
$ iconv -f iso-8859-15 -t utf-8
</source>
</syntaxhighlight>


=== Spaces ===
=== Spaces ===
Git has a filter to be able to normalize with expand. See [https://eev.ee/blog/2016/06/04/converting-a-git-repo-from-tabs-to-spaces/ here].
Git has a filter to be able to normalize with expand. See [https://eev.ee/blog/2016/06/04/converting-a-git-repo-from-tabs-to-spaces/ here].
=== UTF-8 BOM ===
Some old editors started a file by the sequence of bytes [0xEF, 0xBB, 0xBF] to allow the UTF-8 file encoding to be detected. This practice is discouraged nowadays and those should removed.
<syntaxhighlight lang="console">
$ sed -e '1s/^\xef\xbb\xbf//' < bomfile > newfile
</syntaxhighlight>


[[Category:Howto]]
[[Category:Howto]]
[[Category:Contributor guide]]
[[Category:Contributor guide]]

Latest revision as of 23:09, 26 October 2024

Style

EOL at EOF

There is a need for a blank line at end of file.

You can add them with echo.

$ git ls-files | while read f; do tail -n1 $f | read -r _ || echo >> $f; done

UNIX lines

$ dos2unix

Encoding

$ iconv -f iso-8859-15 -t utf-8

Spaces

Git has a filter to be able to normalize with expand. See here.

UTF-8 BOM

Some old editors started a file by the sequence of bytes [0xEF, 0xBB, 0xBF] to allow the UTF-8 file encoding to be detected. This practice is discouraged nowadays and those should removed.

$ sed -e '1s/^\xef\xbb\xbf//' < bomfile > newfile