malxau / yori

Yori is a CMD replacement shell that supports backquotes, job control, and improves tab completion, file matching, aliases, command history, and more.
http://www.malsmith.net/yori/
MIT License
1.24k stars 31 forks source link

move improperly ignores trailing \ or / #92

Closed jstarks closed 3 years ago

jstarks commented 3 years ago

I typically write trailing slashes on directory names that are targets of move/copy to ensure that the target directory exists. To my surprise, yori's move ignores this:

C:\Users\jostarks\tmp>touch foo
C:\Users\jostarks\tmp>move foo bar\
C:\Users\jostarks\tmp>dir bar

 Directory of C:\Users\jostarks\tmp

03/14/2021  03:22 PM                  0 bar
           1 File(s)                  0 bytes
           0 Dir(s)      22,598,160,384 bytes free

copy gets this right:

C:\Users\jostarks\tmp>touch foo
C:\Users\jostarks\tmp>copy foo bar\
CopyFile failed: C:\Users\jostarks\tmp\foo to C:\Users\jostarks\tmp\bar\: The filename, directory name, or volume label syntax is incorrect.
malxau commented 3 years ago

I looked into this and it seems much less surprising.

Yori is using the paths specified in that error report to the API. I didn't debug into kernel, but moving C:\Users\jostarks\tmp\foo to C:\Users\jostarks\tmp\bar\ at the NtSetInformationFile level will create a file.

CMD's behavior is a little different because it detects the trailing slash and appends the file name after it, so the API gets C:\Users\jostarks\tmp\bar\foo , which gets a failure.

I changed this behavior in commit ae3889c62bfb47137a4f90fdd74638acb68c60ab .

However, because the API doesn't behave in the way you're expecting, I have to ask: which other commands should have this behavior?

malxau commented 3 years ago

This should be fixed in 1.50, released today. Please let me know if there are further related issues.