From 7c15ed69c83a8996f036054427b14025bb3266eb Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 16 Sep 2017 22:11:43 +0300 Subject: [PATCH] remove backup option from default cp/mv for posix --- doc.go | 10 +++++----- docstring.go | 10 +++++----- etc/lfrc.example | 4 ++-- os.go | 3 +-- os_windows.go | 1 - 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/doc.go b/doc.go index eed18cac..d38b9455 100644 --- a/doc.go +++ b/doc.go @@ -222,9 +222,9 @@ A first attempt to write such a command may look like this: cmd trash ${{ mkdir -p ~/.trash if [ -z "$fs" ]; then - mv --backup=numbered "$f" ~/.trash + mv "$f" ~/.trash else - IFS="`printf '\n\t'`"; mv --backup=numbered $fs ~/.trash + IFS="`printf '\n\t'`"; mv $fs ~/.trash fi }} @@ -234,7 +234,7 @@ variable is provided. We can use this variable to get rid of the conditional: cmd trash ${{ mkdir -p ~/.trash - IFS="`printf '\n\t'`"; mv --backup=numbered $fx ~/.trash + IFS="`printf '\n\t'`"; mv $fx ~/.trash }} The trash directory is checked each time the command is executed. We can move @@ -242,13 +242,13 @@ it outside of the command so it would only run once at startup: ${{ mkdir -p ~/.trash }} - cmd trash ${{ IFS="`printf '\n\t'`"; mv --backup=numbered $fx ~/.trash }} + cmd trash ${{ IFS="`printf '\n\t'`"; mv $fx ~/.trash }} Since these are one liners, we can drop '{{' and '}}': $mkdir -p ~/.trash - cmd trash $IFS="`printf '\n\t'`"; mv --backup=numbered $fx ~/.trash + cmd trash $IFS="`printf '\n\t'`"; mv $fx ~/.trash Finally note that we set 'IFS' variable manually in these commands. Instead we could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs diff --git a/docstring.go b/docstring.go index b5be1220..37dabdcf 100644 --- a/docstring.go +++ b/docstring.go @@ -232,9 +232,9 @@ A first attempt to write such a command may look like this: cmd trash ${{ mkdir -p ~/.trash if [ -z "$fs" ]; then - mv --backup=numbered "$f" ~/.trash + mv "$f" ~/.trash else - IFS="'printf '\n\t''"; mv --backup=numbered $fs ~/.trash + IFS="'printf '\n\t''"; mv $fs ~/.trash fi }} @@ -245,7 +245,7 @@ conditional: cmd trash ${{ mkdir -p ~/.trash - IFS="'printf '\n\t''"; mv --backup=numbered $fx ~/.trash + IFS="'printf '\n\t''"; mv $fx ~/.trash }} The trash directory is checked each time the command is executed. We can @@ -253,13 +253,13 @@ move it outside of the command so it would only run once at startup: ${{ mkdir -p ~/.trash }} - cmd trash ${{ IFS="'printf '\n\t''"; mv --backup=numbered $fx ~/.trash }} + cmd trash ${{ IFS="'printf '\n\t''"; mv $fx ~/.trash }} Since these are one liners, we can drop '{{' and '}}': $mkdir -p ~/.trash - cmd trash $IFS="'printf '\n\t''"; mv --backup=numbered $fx ~/.trash + cmd trash $IFS="'printf '\n\t''"; mv $fx ~/.trash Finally note that we set 'IFS' variable manually in these commands. Instead we could use the 'ifs' option to set it for all shell commands (i.e. 'set diff --git a/etc/lfrc.example b/etc/lfrc.example index a02163ba..74a9a3a9 100644 --- a/etc/lfrc.example +++ b/etc/lfrc.example @@ -80,8 +80,8 @@ cmd usage $du -h . | less $mkdir -p ~/.trash # move current file or selected files to trash folder -# (see 'man mv' or 'mv --help' for backup options) -cmd trash $mv --backup=numbered $fx ~/.trash +# (also see 'man mv' for backup/overwrite options) +cmd trash $mv $fx ~/.trash # remove current file or selected files (prompting) cmd remove ${{ diff --git a/os.go b/os.go index 6cdb367a..0b193a25 100644 --- a/os.go +++ b/os.go @@ -68,11 +68,10 @@ func putCommand(list []string, dir *dir, copy bool) *exec.Cmd { if copy { sh = "cp" - args = append(args, "-r") + args = append(args, "-R") } else { sh = "mv" } - args = append(args, "--backup=numbered") args = append(args, list...) args = append(args, dir.path) diff --git a/os_windows.go b/os_windows.go index d8545899..186158d4 100644 --- a/os_windows.go +++ b/os_windows.go @@ -65,7 +65,6 @@ func putCommand(list []string, dir *dir, copy bool) *exec.Cmd { } } - // TODO: add backup options // TODO: return 0 on success return exec.Command(sh, args...)