<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"><<a href="mailto:clarson@kergoth.com" target="_blank">clarson@kergoth.com</a>></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"><<a href="mailto:Mikko.Rapeli@bmw.de" target="_blank">Mikko.Rapeli@bmw.de</a>></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>
> That reminds me, there's a shell portability issue / standards-complaince<br>
> issue that's not identified by shellcheck. Typically, to negate a bracket<br>
> expression in a regular expression, one uses ^, e.g. [^a-z] is everything<br>
> that isn't in the range a to z, but that's not the case in shell, e.g. at a<br>
> prompt or in a ${foo#<pattern>}:<br>
><br>
</span>> "[...]a bracket expression as in XBD *RE Bracket Expression* , except<br>
<span>> that the <exclamation-mark> character ( '!' ) shall replace the<br>
> <circumflex> character ( '^' ) in its role in a non-matching list in the<br>
> regular expression notation"<br>
><br>
> So in shell, you'd want [!a-z] rather than [^a-z]. Nearly all shells handle<br>
> both, but the behavior of the latter is actually unspecified according to<br>
> the standard:<br>
><br>
> "A bracket expression starting with an unquoted <circumflex> character<br>
> produces unspecified results."<br>
><br>
> I recently got bitten by this with one of my shell scripts on a system<br>
> 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's just shellcheck that doesn'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>