From f907a553aeb7aed63d74338d4a7e60f6a6665004 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Wed, 25 Oct 2017 18:33:33 +0300 Subject: [PATCH] add interactive flag to cp/mv to avoid overwrite --- os.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/os.go b/os.go index 0b193a25..01b8a624 100644 --- a/os.go +++ b/os.go @@ -72,6 +72,14 @@ func putCommand(list []string, dir *dir, copy bool) *exec.Cmd { } else { sh = "mv" } + + // XXX: POSIX standard states that -i flag shall do nothing when the + // response is not affirmative. Since this command is run with a nil stdin, + // it should not give an affirmative answer and in return this command + // should not overwrite existing files. Our intention here is to use the + // standard -i flag in place of non-standard -n flag to avoid overwrites. + args = append(args, "-i") + args = append(args, list...) args = append(args, dir.path)