[OE-core] what shell programming constructs can we count on in .bbclass files?

Burton, Ross ross.burton at intel.com
Wed Mar 15 11:05:39 UTC 2017


On 15 March 2017 at 10:44, Robert P. J. Day <rpjday at crashcourse.ca> wrote:

>   what shell (or level of POSIX compatibility) does one assume for
> writing shell functions in .bbclass files?
>
>   i'm looking at kernel-fitimage.bbclass and i see this:
>
>   #
>   # Step 7: Sign the image and add public key to U-Boot dtb
>   #
>   if [ "x${UBOOT_SIGN_ENABLE}" = "x1" ] ; then
>
> surely we don't still need to use that ugly "x" prefix hack for string
> comparisons, do we?
>
>   a bit further down:
>
>   do_assemble_fitimage_initramfs() {
>         if echo ${KERNEL_IMAGETYPES} | grep -wq "fitImage" && \
>                 test -n "${INITRAMFS_IMAGE}" ; then
>
> would it not be equivalent to write that second test as:
>
>   [ -n "${INITRAMFS_IMAGE}"]
>
> and so on. what are we allowed to count on?
>

xFOO = xBAR appears to be a long-standing hangover from the 70s, any POSIX
shell should be safe with quoted instead.

Our shell parser *should* be POSIX compliant.  There are a few places where
it isn't, but I believe those should be considered bugs.  At the end of the
day the shell is actually executed by /bin/sh or /bin/bash anyway, so as
long as bitbake can parse it you can use anything.

Ross
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20170315/1d768d16/attachment-0002.html>


More information about the Openembedded-core mailing list