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
|
||||
|
||||
Reference in new issue
Block a user