CC: Tweaked

CC: Tweaked

65M Downloads

Running 'cd ". ."' causes shell to crash

Gamecrafter2020 opened this issue · 14 comments

commented

Minecraft Version

1.20.1

Version

1.115.1

Details

My assumtion of what causes the error is a difference in interpretation of what ". ." means.
Calling 'cd ". ."' will move to a non-existing directory '. .' as that is how it gets interpreted by the shell, which is what will cause fs to throw an error that the current path does not exist.
The reason that 'cd' allows you to go to this non-existing path is that the fs.isDir function returns true for ". .".
This is because Java probably interprets '. .' equal to just '.' (calling 'cd ". ."' in cmd causes the directory to stay the same without any errors) and since the current directory exists, it returns true, but as the CraftOS filesystem interprets it as the name of a folder rather than the current directory, it will allow you to enter this non-existing folder, which then causes issues as soon as the shell tries to autocomplete, as the current working directory does not exist.

commented

maybe you can try virtualbox or wmvare to acess windows and them try it if possible

commented

I'm afraid I can't reproduce this. fs.isDir("..") returns false, and cd .. prints "Not a directory". Would you be able to upload your logs — these will contain some useful info like what operating system you're running, etc...

commented

I'm afraid I can't reproduce this. fs.isDir("..") returns false, and cd .. prints "Not a directory". Would you be able to upload your logs — these will contain some useful info like what operating system you're running, etc...

Yes, that is the expected result if you enter ".." as the argument, but what the issuse is with entering ". ." (with a space in between the dots). If you enter it correctly with quotation marks and a space, the issue will occur.

Image

Image

commented

shell interprets ". ." as two arguments: "." and ".", and cd program just silently ignores the second ".". This is WAI I think as all Lua functions will silently ignores excess arguments.

commented

Or this also could be windows specific issue since CC is using native filesystem

Probably is.

commented

I see what you mean, I think that's because you created a dir with the name ". ."

Image Image

maybe we are using different version I'll try with 1.20.1 cc

commented

Or this also could be windows specific issue since CC is using native filesystem

commented

Weirdly enough, fs.exists works as it should.

Image

commented

This also works for all sorts and kinds of other variations. All of them are interpreted as . by windows

Image

commented

The esiest way to rectify this issue is probably to just adjust the code to check whether the path exists before checking if it is a directory, as that works properly, and if a path does not exist, it cannot be a directory.

commented

Yeah, I'm afraid this appears to be a Windows-specific issue, at least I cannot reproduce on Linux. I've no longer got easy access to a Windows machine, so this is going to require someone else to look at.

Maybe we should just look at doing #2101, at least on Windows. We have a lot of special-handling for Windows's file paths already, and at this point maybe it's no longer worth trying to maintain it.

commented

How practical would it be to get CC to use WSL? All modern Windows have it, though it will make CC more difficult to install.

commented

All modern Windows have it

Sadly it's not installed/enabled by default, and IIRC requires admin permissions to enable.