diff --git a/doc/src/shell.rst b/doc/src/shell.rst index 19a8e1afe3..6ebd9e2abf 100644 --- a/doc/src/shell.rst +++ b/doc/src/shell.rst @@ -21,7 +21,8 @@ Syntax *mv* args = old new old = old filename new = new filename or destination folder - *rm* args = file1 file2 ... + *rm* args = [-f] file1 file2 ... + -f = turn off warnings (optional) file1,file2 = one or more filenames to delete *rmdir* args = dir1 dir2 ... dir1,dir2 = one or more directories to delete diff --git a/src/input.cpp b/src/input.cpp index c504210211..689c016b68 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1218,10 +1218,17 @@ void Input::shell() } else if (strcmp(arg[0],"rm") == 0) { if (narg < 2) error->all(FLERR,"Illegal shell rm command"); if (me == 0) { - for (int i = 1; i < narg; i++) { + int i = 1; + bool warn = true; + if (strcmp(arg[i], "-f") == 0) { + warn = false; + ++i; + } + for (;i < narg; i++) { if (platform::unlink(arg[i]) < 0) - error->warning(FLERR, "Shell command 'rm {}' failed with error '{}'", - arg[i], utils::getsyserror()); + if (warn) + error->warning(FLERR, "Shell command 'rm {}' failed with error '{}'", + arg[i], utils::getsyserror()); } } } else if (strcmp(arg[0],"rmdir") == 0) {