nshlib/[cd|ls|pwd]: add support for local CWD(Current working directory)

This PR will still allow basic shell operations such as cd/ls/pwd to be used even when the environment is disabled.

Signed-off-by: chao an <anchao@lixiang.com>
This commit is contained in:
chao an
2024-12-10 21:06:08 +08:00
committed by Xiang Xiao
parent d7ed69200f
commit e861ea8b53
6 changed files with 43 additions and 34 deletions

View File

@@ -442,6 +442,13 @@ FAR struct console_stdio_s *nsh_newconsole(bool isctty)
/* Initialize the input stream */
INFD(pstate) = STDIN_FILENO;
/* Initialize current working directory */
#ifdef CONFIG_DISABLE_ENVIRON
strlcpy(pstate->cn_vtbl.cwd, CONFIG_LIBC_HOMEDIR,
sizeof(pstate->cn_vtbl.cwd));
#endif
}
return pstate;