Bug 7389

Summary: menuconfig runs malformed run.do_terminal shell script when certain environment variables are present
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Haris Okanovic <haris.okanovic>
Component: coreAssignee: Alejandro Hernandez <alejandro.hernandez>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: Low CC: meta.mr.watcher, meta.watcher, richard.purdie, sgw
Version: unspecified   
Target Milestone: 1.8 M4   
Hardware: x86   
OS: x86_64   
Whiteboard:
OS type for building Yocto: --- Type of Regression: Unknown (Hard to categorize)
Verified: Documentation change: No (bug/feature does not impact docs)

Description Haris Okanovic 2015-03-04 00:08:49 UTC
Try to run `export FOO='${}' && bitbake -c menuconfig busybox;` in the dizzy branch of openembedded-core (bitbake 1.24). Assuming tmux is installed and selected by OE/bitbake, you should see several messages like this before bitbake bails out:

  Trying to run: tmux att -t devshell-31784
  session not found: devshell-31784

The tmux window tries to run a generated shell script `run.do_terminal.##` under tmp-glibc which contains a malformed line `export FOO="${}"`. /bin/sh (dash in my case) immediately fails to parse it with a "Bad substitution" error. As a result, the tmux session ends before bitbake can attach.
Comment 1 Saul Wold 2015-03-04 21:58:33 UTC
Can you be more clear what your use case is for this?  We know that there are 
some issues with dash, so if you are setting an  export with a bad substitution 
for DASH, that does not make sense and will fail, if you can use bash does it 
work correctly?
Comment 2 Haris Okanovic 2015-03-05 16:29:33 UTC
(In reply to comment #1)

> Can you be more clear what your use case is for this?
Our build system is orchestrated by GNU Make, which sets up the bitbake
environment to build OE, run menuconfig, etc. That process (and I don't
know the exact details atm) sets MAKEOVERRIDES to something resembling
a shell substitution, which gets incorrectly translated into the
aforementioned run.do_terminal.## script.

> so if you are setting an  export with a bad substitution for DASH,
> that does not make sense and will fail
`export FOO='${}'` is not a substitution because it's a single-quoted
string. The problem I described happens when a single-quoted string
resembling a substitution is translated into a double-quoted string
(in run.do_terminal.##) and the shell tries to expand it.

> if you can use bash does it work correctly?
Unfortunately no. Bash fails to parse the malformed substitution as
well. Additionally, run.do_terminal.## tries to set BASHOPTS, which
is read-only in bash.
Comment 3 Stephen K Jolley 2015-03-16 19:32:32 UTC
It appears the question has been answered.  If this still needs info, please put the bug back into the needinfo status.
Comment 4 Alejandro Hernandez 2015-04-17 16:24:14 UTC
This is fixed in master here:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=0a791e91e55d30b328ddbd90fdb0d5911c388b96

Although as Martin Jansa stated on the list, it can't be integrated on the current Dizzy branch because it breaks something else, if you need it, hopefully you can still use that patch to fix your problem.