[yocto] Syntax for zero-padding a number in a recipe?

Aaron Biver aaron.biver at gmail.com
Fri Jun 28 09:44:40 PDT 2019


Is there such a thing as zero padding a number in a recipe (or vice versa?
I'd be just as happy starting with a zero-padded number, and converting it
to non-zero-padded.
The crux of the dilemma is that I must have zero-padding for file-naming,
but I CAN'T have zero padding in these numbers when I pass them to the C
code (or the C code treats them as octal).

I'd like to start with:
VERSION_MAJOR="1"
VERSION_MINOR="19"

And turn this into "01" and "19" for purposes of naming the output file
from the recipe.

I've tried the bash-style printf -v, but the recipe kicks the printf lines
out with a parse error.

VERSION_MAJOR="01"
VERSION_MINOR="19"

VERSION_MAJOR_STR=""
VERSION_MINOR_STR=""

printf -v VERSION_MAJOR_STR "%02d" VERSION_MAJOR
printf -v VERSION_MINOR_STR "%02d" VERSION_MINOR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20190628/bb886790/attachment.html>


More information about the yocto mailing list