+Bad dir opened on cd stuff /a or cd stuff \3

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

+Bad dir opened on cd stuff /a or cd stuff \3

Post by *MVV »

Code: Select all

cd stuff /a
cd stuff \3
If I have folder Stuff, such commands allow 'entering' it but it shows empty dir and wrong path D:\stuff \ and I can do nothing inside of this folder. TC shouldn't accept such wrong parameters.
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Confirmed.
Both work this way on the command line.
The first one does not work as button command.

It isn't that TC accepts wrong parameters. It is that TC accepts wrong paths.
If you do "cd c:\folder1\folder2\folder3", TC tries to go to folder c:\folder1\folder2\folder3
If c:\folder1\folder2\folder3 does not exist (anymore, the folder could be deleted), TC tries to go to folder c:\folder1\folder2
If c:\folder1\folder2 does not exist, TC tries c:\folder1
If c:\folder1 does not exist, TC tries c:\
[i]Edited[/i] wrote:Above is true when using cd as button command.
When using the cd command on the command line, TC tries to go to folder c:\folder1\folder2\folder3. If c:\folder1\folder2\folder3 does not exist, TC tries to go to folder c:\folder1\folder2 and select file "folder3". If c:\folder1\folder2 does not exist, TC stops trying.

Apparently TC checks if "stuff " exists and windows reports that it does (ignoring the trailing space), TC then changes working folder without removing the trailing space.
Last edited by white on 2013-11-27, 21:53 UTC, edited 2 times in total.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, I don't currently have any plans to change that. It's happening exactly what "white" describes. I don't want to forbid to open "stuff " because I want to allow users to enter dirs with such irregular names. You can rename a folder to "stuff " by giving the name in shift+F6 like this:
stuff /
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

ghisler,
Problem is that TC 'enters' non-existing dir, not that TC enters dir with training space in name. I have no folder "stuff ", I only have folder "Stuff", so TC shouldn't enter folder "stuff ". It may confuse user.
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

MVV wrote:ghisler,
Problem is that TC 'enters' non-existing dir, not that TC enters dir with training space in name. I have no folder "stuff ", I only have folder "Stuff",
Yes. And if you press F2 (reload) the folder "Stuff" is displayed.

If you do have a folder named "Stuff " and no folder "Stuff", TC enters no folder...

If you do have both folders "Stuff " and "Stuff", TC enters "Stuff ".
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

OK, I have now added a workaround to not call SetCurrentDirectory if the path contains " \" or " /". The problem is that SetCurrentDirectory does not work at all with paths containing spaces at the end.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Beta 9 still enters non-existing directory "F:\stuff " on cd stuff /a.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, this will not be changed - the risk is too high that when I add extra tests, TC will fail to enter other dirs.

What I added was that you can now go to "stuff " with
cd stuff \
and to "stuff \a" with
cd stuff \a
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I got it, maybe it will help someone, but it wasn't the thing that this topic about. :)
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:OK, I have now added a workaround to not call SetCurrentDirectory if the path contains " " or " /". The problem is that SetCurrentDirectory does not work at all with paths containing spaces at the end.
MVV wrote:Beta 9 still enters non-existing directory "F:\stuff " on cd stuff /a.
ghisler(Author) wrote:Sorry, this will not be changed - the risk is too high that when I add extra tests, TC will fail to enter other dirs.
Can you trim trailing spaces from the folder before calling SetCurrentDirectory so we get consistent behavior and TC doesn't go into a non existing folder?
ghisler(Author) wrote:What I added was that you can now go to "stuff " with
cd stuff \
and to "stuff \a" with
cd stuff \a
Confirmed.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Can you trim trailing spaces from the folder before calling SetCurrentDirectory so we get consistent behavior and TC doesn't go into a non existing folder?
Unfortunately you could then no longer enter subdir "stuff ". I'm already trimming trainling spaces when you type it without slash or backslash after the space, e.g.
cd stuff<space>
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:
Can you trim trailing spaces from the folder before calling SetCurrentDirectory so we get consistent behavior and TC doesn't go into a non existing folder?
Unfortunately you could then no longer enter subdir "stuff ". I'm already trimming trainling spaces when you type it without slash or backslash after the space, e.g.
cd stuff<space>
I meant to only trim trailing spaces when you use SetCurrentDirectory..
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

When you type cd docs\user \work, two things may be expected:
1) ignore a space after user and enter folder "docs\user\work";
2) do not ignore space and enter just "docs" because there is no folder "user " in folder "docs".

I doubt that someone will expect third thing (which TC does now):
3) do not ignore space and enter non-existing folder "docs\user \work" showing no contents so operations within it will cause errors.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

What currently happens is that entering "docs\user \work" fails because it's missing, so TC tries to enter "docs\user ". The problem here is that TC tries with SetCurrentDirectory whether it exists or not, so you get again the SetCurrentDirectory bug. I'm not willing to change this function because it could have a lot of negative side effects. People who are themselves typing the space before the / must live with that, sorry.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I did some experiments:
SetCurrentDirectory(L"D:\\Stuff") succeeds
SetCurrentDirectory(L"D:\\Stuff ") succeeds
SetCurrentDirectory(L"D:\\Stuff\\") succeeds
SetCurrentDirectory(L"D:\\Stuff \\") fails
So you can pass path with trailing backslash to SetCurrentDirectory function and it will work only when path is correct. You can do it only for path parts so first call will be with exact path entered by user.
Post Reply