mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-19 19:44:35 +08:00
nshlib: Support "-f" option for command "rm"
In below two cases "rm" command with "-f" option will return 0: a. Bad arguments b. File not exists Following "rm" of GNU coreutils 8.32 GNU coreutils $ rm --version rm (GNU coreutils) 8.32 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Paul Rubin, David MacKenzie, Richard M. Stallman, and Jim Meyering. $ rm /FILE_NOT_EXISTS rm: cannot remove '/FILE_NOT_EXISTS': No such file or directory $ echo $? 1 $ rm -f $ echo $? 0 $ rm -f /FILE_NOT_EXISTS $ echo $? 0 Without this patch nsh> rm nsh: rm: missing required argument(s) nsh> rm /FILE_NOT_EXISTS nsh: rm: unlink failed: 2 nsh> echo $? 1 With this patch nsh> rm -f nsh> echo $? 0 nsh> rm -f /FILE_NOT_EXISTS nsh> echo $? 0 Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
@@ -505,7 +505,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
|
||||
#ifdef NSH_HAVE_DIROPTS
|
||||
# ifndef CONFIG_NSH_DISABLE_RM
|
||||
CMD_MAP("rm", cmd_rm, 2, 3, "[-r] <file-path>"),
|
||||
CMD_MAP("rm", cmd_rm, 2, 3, "[-rf] <file-path>"),
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user