[bitbake-devel] [WIP 0/2] Adding support for shell arithmetics

Olof Johansson olof.johansson at axis.com
Tue May 7 09:22:36 UTC 2013


A week or so I found out that shell fragments in bitbake recipes
don't support shell arithmetics (`$((1+1))`). The reason for this
is the shell lexing throwing NotImplemented exceptions. I've made
some progress in adding support for shell arithmetics, but I have
a hard time getting support for corner cases.

It was suprising to see that currently, only a subset of posix
shell scripts is supported, even though they are sent through to
be executed by the system shell. I think I understand the reason
for having to do the shell lexing; knowing what functions and
variables to export right? But I wonder if it's possible to do
the shell lexing as a best effort, and ignore any errors.

What are the risks with this approach? Is it feasibile to do so?

This patch series is a work in progress, and does support the use
cases we had issues with, however, I currently skip one unit
test, as I can't get it to work. Comments and feedback much

The branch is also pushed to github at:


Olof Johansson (2):
  pysh: Say what kind of token isn't implemented
  initial work on supporting shell arith

 bin/bitbake-selftest       |    1 +
 lib/bb/pysh/pyshlex.py     |   48 ++++++++++++++++--
 lib/bb/tests/codeparser.py |   22 ++++++++
 lib/bb/tests/pysh.py       |  119 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 186 insertions(+), 4 deletions(-)
 create mode 100644 lib/bb/tests/pysh.py


More information about the bitbake-devel mailing list