rm: treat --fake option properly and list what its going to do.

Fixes #1643
This commit is contained in:
Harshavardhana
2016-03-20 14:43:25 -07:00
parent b0e2bde84d
commit 4cecac4ea4
2 changed files with 5 additions and 5 deletions
+2 -3
View File
@@ -23,8 +23,7 @@ install:
- go get -u golang.org/x/tools/cmd/vet
- go get -u github.com/fzipp/gocyclo
- go get -u github.com/remyoudompheng/go-misc/deadcode
- go get -u github.com/alecthomas/gometalinter
- go get -u github.com/client9/misspell
- go get -u github.com/client9/misspell/cmd/misspell
# to run your custom scripts instead of automatic MSBuild
build_script:
@@ -33,7 +32,7 @@ build_script:
- gofmt -s -l pkg
- golint .
- golint github.com/minio/mc/pkg...
- gometalinter --disable-all --linter='misspell:misspell ./*.go:PATH:LINE:COL:MESSAGE' --enable=misspell ./...
- misspell .
- gocyclo -over 40 pkg
- deadcode
- go test -race .
+3 -2
View File
@@ -113,6 +113,7 @@ func checkRmSyntax(ctx *cli.Context) {
// Set command flags from context.
isForce := ctx.Bool("force")
isRecursive := ctx.Bool("recursive")
isFake := ctx.Bool("fake")
if !ctx.Args().Present() {
exitCode := 1
@@ -120,7 +121,7 @@ func checkRmSyntax(ctx *cli.Context) {
}
// For all recursive operations make sure to check for 'force' flag.
if isRecursive && !isForce {
if isRecursive && !isForce && !isFake {
fatalIf(errDummy().Trace(),
"Recursive removal requires --force option. Please review carefully before performing this *DANGEROUS* operation.")
}
@@ -202,7 +203,7 @@ func mainRm(ctx *cli.Context) {
// Support multiple targets.
for _, url := range ctx.Args() {
targetAlias, targetURL, _ := mustExpandAlias(url)
if isRecursive && isForce {
if isRecursive && isForce || isFake {
rmAll(targetAlias, targetURL, isRecursive, isIncomplete, isFake)
} else {
if err := rm(targetAlias, targetURL, isIncomplete, isFake); err != nil {