* Environment variables set by /env/bin/init disappear when script exits
@ 2019-06-11 14:52 Ian Abbott
2019-06-11 15:21 ` Ian Abbott
0 siblings, 1 reply; 3+ messages in thread
From: Ian Abbott @ 2019-06-11 14:52 UTC (permalink / raw)
To: Barebox List
Since commit 90df2a955e3c ("defaultenv: Convert init script to C"), if
the legacy /env/bin/init script is still being used, any environment
variables that were set in the script (such as the PS1 prompt) disappear
when the script exits. I guess it is because the script is now run
directly by run_command(initfile) (initfile is "/env/bin/init") rather
than by run_command("source /env/bin/init").
--
-=( Ian Abbott <abbotti@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268. Registered address: )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Environment variables set by /env/bin/init disappear when script exits
2019-06-11 14:52 Environment variables set by /env/bin/init disappear when script exits Ian Abbott
@ 2019-06-11 15:21 ` Ian Abbott
2019-06-12 6:32 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Ian Abbott @ 2019-06-11 15:21 UTC (permalink / raw)
To: barebox
On 11/06/2019 15:52, Ian Abbott wrote:
> Since commit 90df2a955e3c ("defaultenv: Convert init script to C"), if
> the legacy /env/bin/init script is still being used, any environment
> variables that were set in the script (such as the PS1 prompt) disappear
> when the script exits. I guess it is because the script is now run
> directly by run_command(initfile) (initfile is "/env/bin/init") rather
> than by run_command("source /env/bin/init").
This seems easy to fix in "common/startup.c", assuming it is indeed a
bug. Which of the following fixes would be preferable?
1. Call run_command with a string literal:
run_command("source /env/bin/init");
2. Call run_command with a string constant:
const char *source_initfile = "source /env/bin/init";
run_command(source_initfile);
3. Call run_command with a dynamically constructed string:
char *scr;
scr = basprintf("source %s", initfile);
run_command(scr);
free(scr);
--
-=( Ian Abbott <abbotti@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268. Registered address: )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Environment variables set by /env/bin/init disappear when script exits
2019-06-11 15:21 ` Ian Abbott
@ 2019-06-12 6:32 ` Sascha Hauer
0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2019-06-12 6:32 UTC (permalink / raw)
To: Ian Abbott; +Cc: barebox
Hi Ian,
On Tue, Jun 11, 2019 at 04:21:06PM +0100, Ian Abbott wrote:
> On 11/06/2019 15:52, Ian Abbott wrote:
> > Since commit 90df2a955e3c ("defaultenv: Convert init script to C"), if
> > the legacy /env/bin/init script is still being used, any environment
> > variables that were set in the script (such as the PS1 prompt) disappear
> > when the script exits. I guess it is because the script is now run
> > directly by run_command(initfile) (initfile is "/env/bin/init") rather
> > than by run_command("source /env/bin/init").
>
> This seems easy to fix in "common/startup.c", assuming it is indeed a bug.
> Which of the following fixes would be preferable?
Indeed this behaviour was not intended and should be fixed.
>
> 1. Call run_command with a string literal:
>
> run_command("source /env/bin/init");
I'd probably do something like this:
#define INITFILE "/env/bin/init"
run_command("source " INITFILE);
But I might decide differently if you ask me tomorrow, so do whatever
looks best to you ;)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-12 6:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11 14:52 Environment variables set by /env/bin/init disappear when script exits Ian Abbott
2019-06-11 15:21 ` Ian Abbott
2019-06-12 6:32 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox