Why `cp` is designed this way to overwrite existing files silently?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I create such commands to test cp
commands
In [98]: ls
first.html second.html third.html
In [99]: less first.html second.html third.html
In [100]: cat first.html
first
In [101]: cat second.html
second
In [102]: cat third.html
third
When I copy first.html
to second.html
,
In [103]: cp first.html second.html
In [104]: cat second.html
first
The second.html is overwritten silently without any error prompts.
Nonetheless, If I do it in the desktop GUI, draw a file in with the same name, it will be suffixed an first1.html
automatically.
Doing this avoided to overwrite an existing file accidentally.
Why not follow this pattern to design cp
but to overwrite silently.
I am learning python now and found that it's shutil.copy
completely inherit from the idea of command cp
.
I assume it not a good design and could be easily amended by insert an if check.
Why cp
is designed this way to overwrite existing files silently?
cp
New contributor
add a comment |Â
up vote
0
down vote
favorite
I create such commands to test cp
commands
In [98]: ls
first.html second.html third.html
In [99]: less first.html second.html third.html
In [100]: cat first.html
first
In [101]: cat second.html
second
In [102]: cat third.html
third
When I copy first.html
to second.html
,
In [103]: cp first.html second.html
In [104]: cat second.html
first
The second.html is overwritten silently without any error prompts.
Nonetheless, If I do it in the desktop GUI, draw a file in with the same name, it will be suffixed an first1.html
automatically.
Doing this avoided to overwrite an existing file accidentally.
Why not follow this pattern to design cp
but to overwrite silently.
I am learning python now and found that it's shutil.copy
completely inherit from the idea of command cp
.
I assume it not a good design and could be easily amended by insert an if check.
Why cp
is designed this way to overwrite existing files silently?
cp
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I create such commands to test cp
commands
In [98]: ls
first.html second.html third.html
In [99]: less first.html second.html third.html
In [100]: cat first.html
first
In [101]: cat second.html
second
In [102]: cat third.html
third
When I copy first.html
to second.html
,
In [103]: cp first.html second.html
In [104]: cat second.html
first
The second.html is overwritten silently without any error prompts.
Nonetheless, If I do it in the desktop GUI, draw a file in with the same name, it will be suffixed an first1.html
automatically.
Doing this avoided to overwrite an existing file accidentally.
Why not follow this pattern to design cp
but to overwrite silently.
I am learning python now and found that it's shutil.copy
completely inherit from the idea of command cp
.
I assume it not a good design and could be easily amended by insert an if check.
Why cp
is designed this way to overwrite existing files silently?
cp
New contributor
I create such commands to test cp
commands
In [98]: ls
first.html second.html third.html
In [99]: less first.html second.html third.html
In [100]: cat first.html
first
In [101]: cat second.html
second
In [102]: cat third.html
third
When I copy first.html
to second.html
,
In [103]: cp first.html second.html
In [104]: cat second.html
first
The second.html is overwritten silently without any error prompts.
Nonetheless, If I do it in the desktop GUI, draw a file in with the same name, it will be suffixed an first1.html
automatically.
Doing this avoided to overwrite an existing file accidentally.
Why not follow this pattern to design cp
but to overwrite silently.
I am learning python now and found that it's shutil.copy
completely inherit from the idea of command cp
.
I assume it not a good design and could be easily amended by insert an if check.
Why cp
is designed this way to overwrite existing files silently?
cp
cp
New contributor
New contributor
New contributor
asked 1 min ago
rider dragon
1012
1012
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
rider dragon is a new contributor. Be nice, and check out our Code of Conduct.
rider dragon is a new contributor. Be nice, and check out our Code of Conduct.
rider dragon is a new contributor. Be nice, and check out our Code of Conduct.
rider dragon is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477401%2fwhy-cp-is-designed-this-way-to-overwrite-existing-files-silently%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password