diff options
author | Andreas Schwab <schwab@suse.de> | 2023-03-29 17:00:06 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-06-13 11:28:53 +0200 |
commit | 7f750efcaa86dad4d0b748f27b82c2c066b5435b (patch) | |
tree | 7b6e384dfbba9755c572738007d835b0d3d59138 /bsd-user | |
parent | fdd0df5340a8ebc8de88078387ebc85c5af7b40f (diff) |
linux-user, bsd-user: Preserve incoming order of environment variables in the target
Do not reverse the order of environment variables in the target environ
array relative to the incoming environ order. Some testsuites depend on a
specific order, even though it is not defined by any standard.
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <mvmlejfsivd.fsf@suse.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'bsd-user')
-rw-r--r-- | bsd-user/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bsd-user/main.c b/bsd-user/main.c index cd8b2a670f..b597328118 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -295,8 +295,16 @@ int main(int argc, char **argv) envlist = envlist_create(); - /* add current environment into the list */ + /* + * add current environment into the list + * envlist_setenv adds to the front of the list; to preserve environ + * order add from back to front + */ for (wrk = environ; *wrk != NULL; wrk++) { + continue; + } + while (wrk != environ) { + wrk--; (void) envlist_setenv(envlist, *wrk); } |