[yocto] Bash parser

Olof Johansson olof.johansson at axis.com
Wed Jul 16 02:53:30 PDT 2014


On 14-07-16 11:36 +0200, Isak Lichtenstein wrote:
> In this method I'm using the bash syntax. But a lot of time the
> parser doesn't manage to parse my file properly. Examples:
> 
> 	TMP="file1 file2"
> 	read -a scripts <<< $tmp
> generates
> 	ShellSyntaxError: expecting here-document name, got '<'
> 
> Or 
> 
> 	TMP="file1 file2"
> 	scripts=(${TMP})
> generate
> 	ShellSyntaxError: LexToken(TOKEN,'${TMP}',0,0)
> 
> 
> Other bash commands are parsed properly, but generate an error
> while executing them. Example:
> 	TMP="file1, file2"
> 	tmp=${TMP//,/ }
> generates
> 	Bad substitution
> 	| WARNING: exit code 2 from a shell command.

Note that these features you describe here are all bash
extensions. For Debian users (and I think Ubuntu users as well?),
the default /bin/sh is dash and does not support either of these
extensions. There are cases where the bitbake parser will refuse
valid portable shell script features as well though, like shell
arithmetics, e.g.:

 n=$((n+1))

> Does a page exist somewhere describing the bash features
> supported by the parser and also the execution environment?
> Are arrays supported at all?

I don't know of any such documentation, but if you stick to
portable shell script features, you should be mostly fine.

-- 
olofjn



More information about the yocto mailing list