Hello,

I am sorry if this was already discussed before. I could not find
concrete information in the documentation or the mailing list history.

According to POSIX specifications [1]:

> The array is pointed to by the external variable environ, which is defined as:
>
> extern char **environ;

But in NuttX, it is defined differently [2], when
CONFIG_DISABLE_ENVIRON is not set, like:

> #  define environ get_environ_ptr()

Which calls a function [3] and gets its result. This gives problems if
the apps try to do things like:

> environ = ...;

Which is, in fact, fairly common [4, 5, 6].

So I have two questions:

1. What is the cleanest way to work around the environment update
these apps are trying to do? What are the changes I should make to the
app code so that it can correctly handle setting the environment?

2. Is there any way we can update NuttX to actually define environ
like POSIX specifies, so that we can handle these apps without
modifications?

Thank you very much.

BR

// Marco Casaroli

[1] 
https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/V1_chap08.html
[2] 
https://github.com/apache/nuttx/blob/0fad2ee73f5431cbe34cc02253909f290938cd12/include/stdlib.h#L70
[3] 
https://github.com/apache/nuttx/blob/0fad2ee73f5431cbe34cc02253909f290938cd12/sched/environ/env_getenvironptr.c#L57
[4] 
https://github.com/landley/toybox/blob/c47184b389d5bf97135afbf55aa4a41bc29812eb/lib/env.c#L29
[5] 
https://github.com/landley/toybox/blob/c47184b389d5bf97135afbf55aa4a41bc29812eb/toys/pending/sh.c#L1379
[6] 
https://github.com/mirror/busybox/blob/371fe9f71d445d18be28c82a2a6d82115c8af19d/shell/ash.c#L10574

Reply via email to