<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div class="cooked">
<p>Should FSFE provide some kind of platform for community to
discuss and propose coding standards?</p>
<h3>Rationale</h3>
<p>The (F)LOSS ecosystem is currently mostly focusing on quantity
over quality which results in bloat of software that is not
reliable in a mission critical environment (and thus making it
inferior to proprietary software) or software that requires
“reinventing the wheel” because of authors bad decision (lack of
abstracting → Malpractice).</p>
<p>This proposal is expected to contribute to the solution.</p>
<h3>Practical Example</h3>
<p>Example enforcing <code>IEEE Std 1003.1-2017</code> to check
if variable ‘number’ storing integer <code>5</code> is passing
reqular expression <code>[0-9]</code> in shell vs bourne again
shell.</p>
<p>Bad code:</p>
<pre><code class="hljs bash"><span class="hljs-meta">#!/bin/bash</span>
number=<span class="hljs-string">"5"</span>
<span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$number</span>"</span> =~ [0-9] ]]; <span class="hljs-keyword">then</span> whatever; <span class="hljs-keyword">fi</span>
</code></pre>
<ul>
<li>Works only on systems with dynamic linking</li>
<li>Bash is not part of standard portable OS → Not portable</li>
</ul>
<p>Good code:</p>
<pre><code class="hljs bash"><span class="hljs-meta">#!/bin/sh</span>
<span class="hljs-comment"># shellcheck shell=sh # Written to comply with IEEE Std 1003.1-2017 <a class="moz-txt-link-rfc2396E" href="http://get.posixcertified.ieee.org/"><http://get.posixcertified.ieee.org/></a></span>
number=<span class="hljs-string">"5"</span>
<span class="hljs-keyword">case</span> <span class="hljs-string">"<span class="hljs-variable">$number</span>"</span> <span class="hljs-keyword">in</span> [0-9]) whatever; <span class="hljs-keyword">esac</span>
---</code>
</pre>
</div>
<p><br/>
Discussion at:
<a class="moz-txt-link-freetext" href="https://community.fsfe.org/t/fsfe-defined-coding-standards/597">https://community.fsfe.org/t/fsfe-defined-coding-standards/597</a><br/>
</p>
<pre class="moz-signature" cols="72">--
- Krey</pre>
</body></html>