diff options
Diffstat (limited to 'components/finsh')
| -rw-r--r-- | components/finsh/msh.c | 12 | ||||
| -rw-r--r-- | components/finsh/msh_cmd.c | 2 | ||||
| -rw-r--r-- | components/finsh/shell.c | 3 | ||||
| -rw-r--r-- | components/finsh/shell.h | 12 |
4 files changed, 24 insertions, 5 deletions
diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 49a5d23591..02cbeea196 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -315,12 +315,15 @@ int msh_exec(char* cmd, rt_size_t length) return 0; } #endif -#ifdef DFS_USING_WORKDIR + +#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) + /* change to this directory */ if (chdir(cmd) == 0) { return 0; } #endif + /* truncate the cmd at the first space. */ { char *tcmd; @@ -355,10 +358,12 @@ void msh_auto_complete_path(char *path) struct dirent *dirent = RT_NULL; char *full_path, *ptr, *index; + if (!path) + return; + full_path = (char*)rt_malloc(256); if (full_path == RT_NULL) return; /* out of memory */ - ptr = full_path; if (*path != '/') { getcwd(full_path, 256); @@ -367,7 +372,8 @@ void msh_auto_complete_path(char *path) } else *full_path = '\0'; - index = RT_NULL; ptr = path; + index = RT_NULL; + ptr = path; for (;;) { if (*ptr == '/') index = ptr + 1; if (!*ptr) break; ptr ++; diff --git a/components/finsh/msh_cmd.c b/components/finsh/msh_cmd.c index c11873dc91..a5ccf538b8 100644 --- a/components/finsh/msh_cmd.c +++ b/components/finsh/msh_cmd.c @@ -206,6 +206,7 @@ int cmd_time(int argc, char** argv) } FINSH_FUNCTION_EXPORT_ALIAS(cmd_time, __cmd_time, Execute command with time.); +#ifdef RT_USING_HEAP int cmd_free(int argc, char** argv) { extern void list_mem(void); @@ -214,6 +215,7 @@ int cmd_free(int argc, char** argv) return 0; } FINSH_FUNCTION_EXPORT_ALIAS(cmd_free, __cmd_free, Show the memory usage in the system.); +#endif #endif diff --git a/components/finsh/shell.c b/components/finsh/shell.c index ae099e7e7c..5a6bfc1104 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -70,10 +70,11 @@ const char* finsh_get_prompt() #endif strcpy(finsh_prompt, _PROMPT); -#ifdef DFS_USING_WORKDIR +#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) /* get current working directory */ getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt)); #endif + strcat(finsh_prompt, ">"); return finsh_prompt; diff --git a/components/finsh/shell.h b/components/finsh/shell.h index 448f9e6fbe..92fa4bccb2 100644 --- a/components/finsh/shell.h +++ b/components/finsh/shell.h @@ -33,7 +33,17 @@ #include <rtthread.h> #include "finsh.h" -#define FINSH_USING_HISTORY +/* For historical reasons, users don't define FINSH_USING_HISTORY in rtconfig.h + * but expect the history feature. So you sould define FINSH_USING_HISTORY to 0 + * to disable it from the rtconfig.h. */ +#ifdef FINSH_USING_HISTORY +# if FINSH_USING_HISTORY == 0 +# undef FINSH_USING_HISTORY +# endif +#else +# define FINSH_USING_HISTORY +#endif + #ifndef FINSH_THREAD_PRIORITY #define FINSH_THREAD_PRIORITY 20 #endif |
