nuttx-apps/system/nxinit
wangjianyu3 11c1c6bece system/nxinit: add 'set' builtin command for environment variables
Previously, 'set KEY VALUE' in init.rc was not recognized as a builtin
command. It fell through to posix_spawnp(), which ran it in a
temporary child shell. The environment variable was set only in the
child process and lost when it exited, so services started afterward
never inherited it.

Register cmd_set as an init builtin that calls setenv(key, value, 1)
directly in the init process. The command takes exactly 2 arguments
(key and value). All code is guarded by CONFIG_DISABLE_ENVIRON so it
compiles out when environment support is disabled.

Since child processes inherit init's environment, 'set TZ Asia/Shanghai'
in init.rc now correctly propagates to all subsequently started
services.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-28 09:30:53 -03:00
..
action.c system/nxinit: support compound command execution 2026-08-26 10:00:02 -03:00
action.h system/nxinit: support compound command execution 2026-08-26 10:00:02 -03:00
builtin.c system/nxinit: add 'set' builtin command for environment variables 2026-08-28 09:30:53 -03:00
builtin.h system/nxinit: Add NuttX Init 2026-05-27 17:20:07 -03:00
CMakeLists.txt system/nxinit: Add setprop support for action 2026-08-15 18:51:45 +08:00
import.c system/nxinit: Fix missing check for import argument 2026-06-05 09:43:45 +08:00
import.h system/nxinit: Add NuttX Init 2026-05-27 17:20:07 -03:00
init.c system/nxinit: fix unkown -> unknown typo in resetcause[] 2026-08-26 10:00:02 -03:00
init.h system/nxinit: Add setprop support for action 2026-08-15 18:51:45 +08:00
Kconfig system/nxinit: increase SERVICE_ARGS_MAX default to 16 2026-08-28 09:30:53 -03:00
Make.defs system/nxinit: Add NuttX Init 2026-05-27 17:20:07 -03:00
Makefile system/nxinit: Add setprop support for action 2026-08-15 18:51:45 +08:00
parser.c system/nxinit: fix event-board timing 2026-08-24 20:11:14 +08:00
parser.h system/nxinit: Parse default cpu-specific configs 2026-08-22 17:36:04 +08:00
property.h system/nxinit: Add setprop support for action 2026-08-15 18:51:45 +08:00
property_simple.c system/nxinit: Add setprop support for action 2026-08-15 18:51:45 +08:00
service.c system: nxinit: bound debug argv dump 2026-07-07 09:47:23 +08:00
service.h system/nxinit: Let use a define to define the class max cmds 2026-05-27 17:20:07 -03:00