Do a stat on files for non-recursive rm before removing to detect non-existing files

This commit is contained in:
Krishna Srinivas
2015-11-18 22:26:07 -08:00
parent 3d29ad2c17
commit cecc409a71
+10
View File
@@ -115,6 +115,16 @@ func checkRmSyntax(ctx *cli.Context) {
cli.ShowCommandHelpAndExit(ctx, "rm", exitCode)
}
if !isRecursive {
URLs, err := args2URLs(ctx.Args())
fatalIf(err.Trace(ctx.Args()...), "Unable to parse arguments.")
for _, url := range URLs {
if _, _, err := url2Stat(url); err != nil {
fatalIf(err.Trace(url), "Unable to stat.")
}
}
}
if isRecursive && !isForce {
fatalIf(errDummy().Trace(),
"Recursive removal requires --force option. Please review carefully before performing this *DANGEROUS* operation.")