[OE-core] [PATCH] terminal.bbclass: use var-SHELL as the shebang of wrapper script

Andre McCurdy armccurdy at gmail.com
Tue Sep 4 19:14:18 UTC 2018


On Tue, Sep 4, 2018 at 9:36 AM, Alejandro Enedino Hernandez Samaniego
<alejandro.enedino.hernandez-samaniego at xilinx.com> wrote:
> Hey Hongxu,
>
>
>
> On 09/02/2018 10:52 PM, Hongxu Jia wrote:
>>
>> On 2018年09月01日 08:14, Alejandro Enedino Hernandez Samaniego wrote:
>>>
>>> Hey Hongxu,
>>>
>>>
>>> On 08/24/2018 01:54 AM, Hongxu Jia wrote:
>>>>
>>>> The devshell.bbclass set var-SHELL to var-DEVSHELL, and terminal.bbclass
>>>> initial var-SHELL with `bash'. Keep sync with it, use var-SHELL rather
>>>> than hardcoded `/bin/sh' as the shebang of wrapper script.
>>>>
>>>> On Ubuntu host, default shell is dash (/bin/sh -> dash), even though
>>>> we assign var-SHELL with `/bin/bash', the wrapper script is still
>>>> dashism.
>>>>
>>>> Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
>>>> ---
>>>>   meta/classes/terminal.bbclass | 3 ++-
>>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/meta/classes/terminal.bbclass
>>>> b/meta/classes/terminal.bbclass
>>>> index a27e10c..73e765d 100644
>>>> --- a/meta/classes/terminal.bbclass
>>>> +++ b/meta/classes/terminal.bbclass
>>>> @@ -25,7 +25,8 @@ def emit_terminal_func(command, envdata, d):
>>>>       bb.utils.mkdirhier(os.path.dirname(runfile))
>>>>         with open(runfile, 'w') as script:
>>>> -        script.write('#!/bin/sh -e\n')
>>>> +        script.write('#!/usr/bin/env %s\n' % d.getVar('SHELL'))
>>>> +        script.write('set -e\n')
>>>
>>> This is causing a bug on several systems, I believe that it is because
>>> the way our systems are set up,
>>> basically, our running shell isn't necessarily $SHELL, so it is causing
>>> the process to exit immediately,
>>> anything thats using this class is affected, devshell, menuconfig, etc.
>>>
>>>
>>> $ echo $SHELL
>>> /bin/csh
>>>
>>> $ echo $0
>>> /bin/bash
>>>
>>
>> The csh does not support `export', in you case, you should correct
>> var-SHELL to align with $0,
>>
>> Such as:
>> $ usermod <username> -s $0
>
>
> I absolutely agree, but as I was saying, because the way the system is set
> up, it does not allow me to do so.

Maybe I'm missing something, but what's the advantage of using SHELL
to run this little wrapper script rather than hardcoding /bin/sh ?

Task shell scripts created by bitbake use hardcoded /bin/sh (see
bitbake/lib/bb/build.py -> shell_trap_code())



More information about the Openembedded-core mailing list