diff options
| author | Yang Liu <liuyang22@iscas.ac.cn> | 2025-01-22 17:29:21 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-22 10:29:21 +0100 |
| commit | 89dcd2566bfa1ef93e740b568cbc3aa5c5409aa4 (patch) | |
| tree | af3e95e694fb620ccb2d955a74a0aab0ad14c29e /src/tools | |
| parent | 314edea645acacf03930af17aa01783ca735306a (diff) | |
| download | box64-89dcd2566bfa1ef93e740b568cbc3aa5c5409aa4.tar.gz box64-89dcd2566bfa1ef93e740b568cbc3aa5c5409aa4.zip | |
Fixed various issues introduced in the env infra refactor (#2281)
* Open trace file again after apply env files * dynrec_df=1 by default * more fixes * more fixes * more
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/env.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/tools/env.c b/src/tools/env.c index ae19c8ad..4f61083a 100644 --- a/src/tools/env.c +++ b/src/tools/env.c @@ -66,6 +66,23 @@ static const char default_rcfile[] = "BOX64_EXIT=1\n" ; + +static void addNewEnvVar(const char* s) +{ + if (!s) return; + char* p = box_strdup(s); + char* e = strchr(p, '='); + if (!e) { + printf_log(LOG_INFO, "Invalid specific env. var. '%s'\n", s); + box_free(p); + return; + } + *e = '\0'; + ++e; + setenv(p, e, 1); + box_free(p); +} + static void applyCustomRules() { if (BOX64ENV(log) == LOG_NEVER) { @@ -142,12 +159,12 @@ static void applyCustomRules() if (box64env.exit) exit(0); - if (box64env.env) setenv("BOX64_ENV", "1", 1); - if (box64env.env1) setenv("BOX64_ENV1", "1", 1); - if (box64env.env2) setenv("BOX64_ENV2", "1", 1); - if (box64env.env3) setenv("BOX64_ENV3", "1", 1); - if (box64env.env4) setenv("BOX64_ENV4", "1", 1); - if (box64env.env5) setenv("BOX64_ENV5", "1", 1); + if (box64env.env) addNewEnvVar(box64env.env); + if (box64env.env1) addNewEnvVar(box64env.env1); + if (box64env.env2) addNewEnvVar(box64env.env2); + if (box64env.env3) addNewEnvVar(box64env.env3); + if (box64env.env4) addNewEnvVar(box64env.env4); + if (box64env.env5) addNewEnvVar(box64env.env5); } static void trimStringInplace(char* s) |