Re: Environment variables set by /env/bin/init disappear when script exits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> || 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux