Skip to content

Adding support for shell arithmetics

Olof Johansson bitbake-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2pysh: Say what kind of token isn't implementedlib/bb/pysh/pyshlex.py+1 -10 replies
2/2initial work on supporting shell arithbin/bitbake-selftest lib/bb/pysh/pyshlex.py lib/bb/tests/codeparser.py +1 more+185 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [WIP 0/2] Adding support for shell arithmetics

Hi,

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 appreciated!

The branch is also pushed to github at:

https://github.com/olof/bitbake/tree/topic/shlex_shell_arith

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
Signature · 1 line
1.7.10.4