remove backup option from default cp/mv for posix
This commit is contained in:
1 parent
263c9d9fef
commit
7c15ed69c8
5 files changed
+13
-15
No files matched your search
@@ -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
|
||||
|
||||
+5
-5
@@ -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
|
||||
|
||||
+2
-2
@@ -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 ${{
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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...)
|
||||
|
||||
Reference in new issue
Block a user