-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nshlib/prompt: add multiple sources support at runtime #2300
nshlib/prompt: add multiple sources support at runtime #2300
Conversation
This patch fixes CI blocking warnings of unused `fs` variables in hostfs.c. It blocks apache/nuttx-apps#2300. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
41b4cd3
to
8110f13
Compare
but you can set CONFIG_NSH_PROMPT_STRING to different string in each defconfig. |
@xiaoxiang781216 using NSH_PROMPT_STRING config can't solve the issue as the master and remote node shares the same NSH binary, thus both master and remote consoles show the same prompt string, this confuses NSH console users. |
If so, let's use the approach like bash: https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html |
8110f13
to
eb467be
Compare
@xiaoxiang781216 did you mean that NSH already supports special variables Or did you mean that we should add PS1 alike feature to NSH? that may need more time/effort as I am still unfamilar with NSH. |
NSH doesn't support PS1 yet.
it's simple, something like this:
|
@xiaoxiang781216 we may need check how readline works. it has an internal reference of g_nshprompt. |
eb467be
to
b506b26
Compare
b506b26
to
02d4a61
Compare
@xiaoxiang781216 please see if this version works or not? it has PS1 support. |
be12c71
to
3a9c08e
Compare
3a9c08e
to
7d73c9c
Compare
8acf84d
to
945a347
Compare
945a347
to
9335d36
Compare
65eca55
to
a026515
Compare
fd75c3a
to
cd802bf
Compare
0a1cdbe
to
187726a
Compare
Currently NSH prompt is defined at build time, thus improper for AMP cases where the same NSH binary is used on different nodes as the same NSH prompt shows on all nodes. This patch attempts to support runtime prompt string population from ordered sources: - the environment variable defined by NSH_PROMPT_ENV plus suffix - the NSH_PROMPT_STRING - the HOSTNAME plus suffix The suffix is defined by NSH_PROMPT_SUFFIX so that to clearly separate the command inputs. Changes in `nshlib/` - Kconfig: add configs NSH_PROMPT_MAX/ENV/SUFFIX etc - nsh.h: adjust g_nshprompt defs, add nsh_update_prompt - nsh_parse.c relocate g_nshpromt to nsh_prompt.c - nsh_init.c revise to use nsh_update_prompt once - nsh_session.c revise to use methods in nsh_prompt.c - Makefile add nsh_prompt.c - CMakeLists.txt add nsh_prompt.c New additions in `nshlib/` - nsh_prompt.c prompt related data structures and methods. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
187726a
to
9aae906
Compare
Summary
Currently NSH prompt string is determined at build time, this is inflexible in some AMP cases where the same NSH binary runs on different AMP nodes as the same prompt string is showed everywhere. Yet another issue is that empty
NSH_RPOMPT_STRING
config leads to no prompt at all, making people questioning if the system is stalled.This patch attempts to solve these issues by adding ordered runtime fallbacks for empty NSH_PROMPT_STRING case from sources like environment variable (default to
PS1
) and hostname, both suffixed with>
. If all sources are empty, the non-empty suffix string will be used. The patch has little impacts on for existing use cases with non-empty NSH_PROMPT_STRING .Changes in nshlib/ folder:
New additions in
nshlib/
Impact
NSH app
Testing
Checked with CanMV230
Limits
All sources are plaintext, there is no shell escaping, terminfo escaping, command embedding etc.