| Message ID | 20251125073454.1282407-1-changqing.li@windriver.com |
|---|---|
| State | New |
| Headers | show |
| Series | bitbake-setup: Avoid unexpected positional parameter propagation when sourcing scripts | expand |
Le mar. 25 nov. 2025 à 08:34, Changqing Li via lists.openembedded.org < changqing.li=windriver.com@lists.openembedded.org> a écrit : > From: Changqing Li <changqing.li@windriver.com> > > Using `set` to define positional parameters in the current shell causes > those parameters to persist. When another script is sourced in the same > shell without explicit arguments, it unexpectedly inherits these > positional parameters. This change prevents such unintended propagation. > > Signed-off-by: Changqing Li <changqing.li@windriver.com> > --- > bin/bitbake-setup | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/bin/bitbake-setup b/bin/bitbake-setup > index 75be90940..7f77bda55 100755 > --- a/bin/bitbake-setup > +++ b/bin/bitbake-setup > @@ -184,7 +184,7 @@ def setup_bitbake_build(bitbake_config, layerdir, > setupdir, thisdir, update_bb_c > > def _make_init_build_env(builddir, oeinitbuildenvdir): > builddir = os.path.realpath(builddir) > - cmd = "cd {}\nset {}\n. > ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir) > + cmd = "cd {}\n. ./oe-init-build-env > {}\n".format(oeinitbuildenvdir, builddir) > Sadly, dash does not support this (I used "set {}", to enable its support). Maybe use "set --" to remove any added positional argument? That seem to work: $ dash $ set A $ echo $1 A $ set -- $ echo $1 $ Regards, > initbuild_in_builddir = os.path.join(builddir, 'init-build-env') > > with open(initbuild_in_builddir, 'w') as f: > -- > 2.34.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#18487): > https://lists.openembedded.org/g/bitbake-devel/message/18487 > Mute This Topic: https://lists.openembedded.org/mt/116465767/4316185 > Group Owner: bitbake-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ > yoann.congal@smile.fr] > -=-=-=-=-=-=-=-=-=-=-=- > >
On 11/25/25 15:49, Yoann Congal wrote: > ** > *CAUTION: This email comes from a non Wind River email account!* > Do not click links or open attachments unless you recognize the sender > and know the content is safe. > > > Le mar. 25 nov. 2025 à 08:34, Changqing Li via lists.openembedded.org > <https://urldefense.com/v3/__http://lists.openembedded.org__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXlO84kBcw$> > <changqing.li > <https://urldefense.com/v3/__http://changqing.li__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXn9tMDYxw$>=windriver.com@lists.openembedded.org> > a écrit : > > From: Changqing Li <changqing.li@windriver.com> > > Using `set` to define positional parameters in the current shell > causes > those parameters to persist. When another script is sourced in the > same > shell without explicit arguments, it unexpectedly inherits these > positional parameters. This change prevents such unintended > propagation. > > Signed-off-by: Changqing Li <changqing.li@windriver.com> > --- > bin/bitbake-setup | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/bin/bitbake-setup b/bin/bitbake-setup > index 75be90940..7f77bda55 100755 > --- a/bin/bitbake-setup > +++ b/bin/bitbake-setup > @@ -184,7 +184,7 @@ def setup_bitbake_build(bitbake_config, > layerdir, setupdir, thisdir, update_bb_c > > def _make_init_build_env(builddir, oeinitbuildenvdir): > builddir = os.path.realpath(builddir) > - cmd = "cd {}\nset {}\n. > ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir) > + cmd = "cd {}\n. ./oe-init-build-env > {}\n".format(oeinitbuildenvdir, builddir) > > > Sadly, dash does not support this (I used "set {}", to enable its > support). > Maybe use "set --" to remove any added positional argument? That seem > to work: > $ dash > $ set A > $ echo $1 > A > $ set -- > $ echo $1 Thanks, I will update with a V2 patch. //Changqing > > $ > > Regards, > > initbuild_in_builddir = os.path.join(builddir, > 'init-build-env') > > with open(initbuild_in_builddir, 'w') as f: > -- > 2.34.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#18487): > https://lists.openembedded.org/g/bitbake-devel/message/18487 > <https://urldefense.com/v3/__https://lists.openembedded.org/g/bitbake-devel/message/18487__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXnBZyZ1XA$> > Mute This Topic: > https://lists.openembedded.org/mt/116465767/4316185 > <https://urldefense.com/v3/__https://lists.openembedded.org/mt/116465767/4316185__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXnpWepkjA$> > Group Owner: bitbake-devel+owner@lists.openembedded.org > <mailto:bitbake-devel%2Bowner@lists.openembedded.org> > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub > <https://urldefense.com/v3/__https://lists.openembedded.org/g/bitbake-devel/unsub__;!!AjveYdw8EvQ!fu8ZgVhqx6-gTH5HK3ploud4sYOeN07Y-QBQseosoDoeG7EdjNhWwwBCGKqQXh-mZhMOXASG8P90qiwYdFZ_AXkFZYk5mQ$> > [yoann.congal@smile.fr] > -=-=-=-=-=-=-=-=-=-=-=- > > > > -- > Yoann Congal > Smile ECS
diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 75be90940..7f77bda55 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -184,7 +184,7 @@ def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_c def _make_init_build_env(builddir, oeinitbuildenvdir): builddir = os.path.realpath(builddir) - cmd = "cd {}\nset {}\n. ./oe-init-build-env\n".format(oeinitbuildenvdir, builddir) + cmd = "cd {}\n. ./oe-init-build-env {}\n".format(oeinitbuildenvdir, builddir) initbuild_in_builddir = os.path.join(builddir, 'init-build-env') with open(initbuild_in_builddir, 'w') as f: