[shell] define FINSH_PROMPT as finsh_get_prompt when FINSH_USING_MSH enabled

When MSH enabled, the prompt will change at the two shells. So we should
use dynamic prompt when FINSH_USING_MSH defined.
This commit is contained in:
Grissiom 2014-04-08 15:12:44 +08:00
parent 16eb9bbed5
commit 841898abe2
2 changed files with 6 additions and 2 deletions

View File

@ -54,8 +54,10 @@ ALIGN(RT_ALIGN_SIZE)
static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE]; static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE];
struct finsh_shell* shell; struct finsh_shell* shell;
#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) #if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
#if defined(RT_USING_DFS)
#include <dfs_posix.h> #include <dfs_posix.h>
#endif
const char* finsh_get_prompt() const char* finsh_get_prompt()
{ {
#define _MSH_PROMPT "msh " #define _MSH_PROMPT "msh "
@ -68,8 +70,10 @@ const char* finsh_get_prompt()
#endif #endif
strcpy(finsh_prompt, _PROMPT); strcpy(finsh_prompt, _PROMPT);
#ifdef DFS_USING_WORKDIR
/* get current working directory */ /* get current working directory */
getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt)); getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
#endif
strcat(finsh_prompt, ">"); strcat(finsh_prompt, ">");
return finsh_prompt; return finsh_prompt;

View File

@ -43,7 +43,7 @@
#define FINSH_CMD_SIZE 80 #define FINSH_CMD_SIZE 80
#define FINSH_OPTION_ECHO 0x01 #define FINSH_OPTION_ECHO 0x01
#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) #if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
#define FINSH_PROMPT finsh_get_prompt() #define FINSH_PROMPT finsh_get_prompt()
const char* finsh_get_prompt(void); const char* finsh_get_prompt(void);
#else #else