[yocto] bash specific syntax in bbclass files

Paul Eggleton paul.eggleton at linux.intel.com
Thu May 2 01:07:55 PDT 2013


On Wednesday 01 May 2013 19:13:19 seth bollinger wrote:
> I recently ran into a problem in
> meta-raspberrypi/classes/sdcard_image-rpi.bbclass
> 
> The following was run through my default debian dash shell (I thought I
> switched a while back, but I must have reverted my VM image or
> something...).
> 
>    # If SDIMG_ROOTFS_TYPE is a .xz file use xzcat
>    if [[ "$SDIMG_ROOTFS_TYPE" == *.xz ]]
>    then
> 
> The bash specific syntax ([[) failed in dash causing the "else" path to
> be traversed instead of the correct "then" path.  The failure was silent
> and resulted in a blind copy of a compressed rootfs to the sdcard
> image.  Of course this didn't run.  :)
> 
> 1.  Is there particular shell syntax that class files should stick too?

No bashisms should be used, so the above should really be changed.

> 2.  I couldn't find a wildcard string search in dash.  Can anyone
> suggest a more shell agnostic way to do this?

AFAIK grep or awk is the only way.

> 3.  Is there a way to guarantee we're running in bash if we're using
> bash specific syntax?

Not that I'm aware of.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the yocto mailing list