'copy' command overwrites original

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

'copy' command overwrites original

Postby Akuma » 2019-8-06 @ 09:44

Can anyone confirm/reproduces this ?

I wanted to copy a file in dosbox, instead of pressing shift I hit the enter key resulting in a malformed command.
This should result in a syntax error but it does not: (it destroys the file in the process)

Code: Select all
C:\>copy UNP412B.EXE
 UNP412B.EXE
   1 File(s) copied.
C::\>dir UNP412B.EXE
Directory of C:\.
UNP412B  EXE                          0 06-08-2019 11:30
    1 Files(s)                                0 Bytes.
    0 Dir(s)                 262,111,744 Bytes free.
C:\>


Dosbox Version: 0.74-4.3 (compiled with heavy debug enabled)

'copy' command overwrites original
Akuma
Newbie
 
Posts: 57
Joined: 2019-7-24 @ 14:47

Re: 'copy' command overwrites original

Postby Zup » 2019-8-06 @ 10:16

Not a malformed command.

In copy, the origin is required, but destination is not required. If an user omits destination, the files are copied to current directory.

(I'm not sure if it warned about existing files)
I have traveled across the universe and through the years to find Her.
Sometimes going all the way is just a start...

I'm selling some stuff!
User avatar
Zup
Oldbie
 
Posts: 1286
Joined: 2003-10-04 @ 12:16

Re: 'copy' command overwrites original

Postby ripsaw8080 » 2019-8-06 @ 10:25

It's a known issue with the COPY command. Real DOS would stop you with a "File cannot be copied onto itself" error message. Can be worse if you do a COPY *.* command, which truncates all files in the current directory to zero bytes. Anyway, for the time being, just don't do it. ;)
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4407
Joined: 2006-4-25 @ 23:24

Re: 'copy' command overwrites original

Postby Akuma » 2019-8-06 @ 10:44

@zup
And there I thought I found a bug, I should know better by now. Thanks.

@ripsaw:
I don't think my pinky would trip over the shift and hit the [8][SHIFT][.][8][SHIFT] key. But I moved my beverage to the other side ;)
Akuma
Newbie
 
Posts: 57
Joined: 2019-7-24 @ 14:47

Re: 'copy' command overwrites original

Postby ripsaw8080 » 2019-8-06 @ 11:31

Well, just as you mistakenly left out a destination when copying a single file, it's possible to do the same when copying multiple files, so just be careful, and also don't use DOSBox to do file management on irreplaceable files. :)
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4407
Joined: 2006-4-25 @ 23:24


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 1 guest