[OE-core] shell script guidelines in oe-core? (was Re: [PATCH v4] create-pull-request: cleanup bashisms)

Christopher Larson clarson at kergoth.com
Sun Aug 16 01:38:18 UTC 2015


On Fri, Aug 14, 2015 at 3:01 PM, Christopher Larson <clarson at kergoth.com>
wrote:

> On Wed, Aug 12, 2015 at 11:27 PM, <Mikko.Rapeli at bmw.de> wrote:
>
>> On Wed, Aug 12, 2015 at 10:51:26AM -0700, Christopher Larson wrote:
>> > That reminds me, there's a shell portability issue /
>> standards-complaince
>> > issue that's not identified by shellcheck. Typically, to negate a
>> bracket
>> > expression in a regular expression, one uses ^, e.g. [^a-z] is
>> everything
>> > that isn't in the range a to z, but that's not the case in shell, e.g.
>> at a
>> > prompt or in a ${foo#<pattern>}:
>> >
>> >     "[...]a bracket expression as in XBD *RE Bracket Expression* ,
>> except
>> > that the <exclamation-mark> character ( '!' ) shall replace the
>> > <circumflex> character ( '^' ) in its role in a non-matching list in the
>> > regular expression notation"
>> >
>> > So in shell, you'd want [!a-z] rather than [^a-z]. Nearly all shells
>> handle
>> > both, but the behavior of the latter is actually unspecified according
>> to
>> > the standard:
>> >
>> >     "A bracket expression starting with an unquoted <circumflex>
>> character
>> > produces unspecified results."
>> >
>> > I recently got bitten by this with one of my shell scripts on a system
>> > running dash.
>>
>> Does checkbashisms warn about this?
>
>
> Finally got around to checking, and yeah, checkbashisms does spot this
> one, it's just shellcheck that doesn't (yet, opened a bug upstream).


Update: checkbashisms and shellcheck both check for this now.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20150815/2a60def0/attachment-0002.html>


More information about the Openembedded-core mailing list