<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 14, 2015 at 3:01 PM, Christopher Larson <span dir="ltr">&lt;<a href="mailto:clarson@kergoth.com" target="_blank">clarson@kergoth.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div class="gmail_quote">On Wed, Aug 12, 2015 at 11:27 PM,  <span dir="ltr">&lt;<a href="mailto:Mikko.Rapeli@bmw.de" target="_blank">Mikko.Rapeli@bmw.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Wed, Aug 12, 2015 at 10:51:26AM -0700, Christopher Larson wrote:<br>
&gt; That reminds me, there&#39;s a shell portability issue / standards-complaince<br>
&gt; issue that&#39;s not identified by shellcheck. Typically, to negate a  bracket<br>
&gt; expression in a regular expression, one uses ^, e.g. [^a-z] is everything<br>
&gt; that isn&#39;t in the range a to z, but that&#39;s not the case in shell, e.g. at a<br>
&gt; prompt or in a ${foo#&lt;pattern&gt;}:<br>
&gt;<br>
</span>&gt;     &quot;[...]a bracket expression as in XBD *RE Bracket Expression* , except<br>
<span>&gt; that the &lt;exclamation-mark&gt; character ( &#39;!&#39; ) shall replace the<br>
&gt; &lt;circumflex&gt; character ( &#39;^&#39; ) in its role in a non-matching list in the<br>
&gt; regular expression notation&quot;<br>
&gt;<br>
&gt; So in shell, you&#39;d want [!a-z] rather than [^a-z]. Nearly all shells handle<br>
&gt; both, but the behavior of the latter is actually unspecified according to<br>
&gt; the standard:<br>
&gt;<br>
&gt;     &quot;A bracket expression starting with an unquoted &lt;circumflex&gt; character<br>
&gt; produces unspecified results.&quot;<br>
&gt;<br>
&gt; I recently got bitten by this with one of my shell scripts on a system<br>
&gt; running dash.<br>
<br>
</span>Does checkbashisms warn about this?</blockquote></div><br></span>Finally got around to checking, and yeah, checkbashisms does spot this one, it&#39;s just shellcheck that doesn&#39;t (yet, opened a bug upstream).</blockquote></div><br>Update: checkbashisms and shellcheck both check for this now.<br>-- <br><div class="gmail_signature">Christopher Larson<br>clarson at kergoth dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Maintainer - Tslib<br>Senior Software Engineer, Mentor Graphics</div>
</div></div>