diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 86985c561cb11752b4325b33ee0f90356366b402..18182ca2646a094587c3cb9ad2c985550f06ce24 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -257,21 +257,6 @@ int msh_exec_module(const char *cmd_line, int size) rt_free(pg_name); return ret; } - -int system(const char *command) -{ - int ret = -RT_ENOMEM; - char *cmd = rt_strdup(command); - - if (cmd) - { - ret = msh_exec(cmd, rt_strlen(cmd)); - rt_free(cmd); - } - - return ret; -} -RTM_EXPORT(system); #endif /* defined(RT_USING_MODULE) && defined(RT_USING_DFS) */ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp) diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 7d8ec2e8b44e5e0501aa2daf9cf5512f5a47e0c6..3b1627d82a8220433dd828b03d013b13e9b6d3f4 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -319,16 +319,6 @@ int remove(const char *filename) #endif } -#if defined(RT_USING_FINSH) && defined(RT_USING_MODULE) && defined(RT_USING_DFS) -/* use system(const char *string) implementation in the msh */ -#else -int system(const char *string) -{ - extern int __rt_libc_system(const char *string); - return __rt_libc_system(string); -} -#endif - #ifdef __MICROLIB #include diff --git a/components/libc/compilers/common/stdlib.c b/components/libc/compilers/common/stdlib.c index 16a13afb83a3916ec6605dc251c547c59f74fb7a..6cc0b9fdacd199a32e030829ec7551747810bdec 100644 --- a/components/libc/compilers/common/stdlib.c +++ b/components/libc/compilers/common/stdlib.c @@ -25,11 +25,21 @@ void __rt_libc_exit(int status) } } -int __rt_libc_system(const char *string) -{ #ifdef RT_USING_MSH +int system(const char *command) +{ extern int msh_exec(char *cmd, rt_size_t length); - msh_exec((char*)string, rt_strlen(string)); -#endif - return 0; + + int ret = -RT_ENOMEM; + char *cmd = rt_strdup(command); + + if (cmd) + { + ret = msh_exec(cmd, rt_strlen(cmd)); + rt_free(cmd); + } + + return ret; } +RTM_EXPORT(system); +#endif diff --git a/components/libc/compilers/dlib/syscalls.c b/components/libc/compilers/dlib/syscalls.c index e1c9562b3a81bab6a3b71d16db6974692e144ad7..1ee6a3bc12ba4b10193a2896e03af7afb96af3ca 100644 --- a/components/libc/compilers/dlib/syscalls.c +++ b/components/libc/compilers/dlib/syscalls.c @@ -6,7 +6,6 @@ * Change Logs: * Date Author Notes * 2021-02-13 Meco Man implement exit() and abort() - * 2021-02-20 Meco Man add system() */ #include @@ -17,9 +16,3 @@ void __exit (int status) __rt_libc_exit(status); while(1); } - -int system(const char * string) -{ - extern int __rt_libc_system(const char *string); - return __rt_libc_system(string); -} diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c index 8b7ff9efdb4561f66cf3fa47091c83b3ca75c0cb..f5a2c16ecc774e36d30bb5e62a87e717712ff9b0 100644 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ b/components/libc/compilers/gcc/newlib/syscalls.c @@ -308,12 +308,6 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) #endif } -void _system(const char *s) -{ - extern int __rt_libc_system(const char *string); - __rt_libc_system(s); -} - /* for exit() and abort() */ __attribute__ ((noreturn)) void _exit (int status) {