[TC 11.51] Quotes are removed from first parameter of the cd command

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

[TC 11.51] Quotes are removed from first parameter of the cd command

Post by *white »

Suppose you have the following 2 files among other files:
test 1.txt
test 2.txt

Type at the command line in TC:

Code: Select all

cd "test 1.*" "test 2.*"
The quotes from the first parameter are removed, resulting in the wrong result.
The same happens when you put the command under a button, but then you can add a space before the first parameter to make it work.
User avatar
petermad
Power Member
Power Member
Posts: 15997
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *petermad »

Confirmed!
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50383
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *ghisler(Author) »

The quotes are removed because when the user uses something like
cd "c:\path"
TC cannot switch to "c:\path" and has to remove the quotes.
I don't currently see how I can fix that. :(
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *white »

ghisler(Author) wrote: 2025-04-13, 08:42 UTC I don't currently see how I can fix that. :(
Perhaps like this:
  1. If there is no wildcard in the command, remove quotes from the first quoted argument, as done currently.
  2. If there is a wildcard in the command and the first quoted argument ends with a backslash, remove its quotes, treating it as a directory path.
  3. If there is a wildcard in the command and the first quoted argument does not end with a backslash, don't remove its quotes but extract any leading directory path unquoted and keep the filter quoted. For example:

    Code: Select all

    cd "c:\test\test 1.*"
    is transformed internally by TC into:

    Code: Select all

    cd c:\test\"test 1.*"
User avatar
petermad
Power Member
Power Member
Posts: 15997
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *petermad »

How about:
If there is a wildcard in any part of the command - treat it as a filter and don't remove the quotes.

If the user puts a wildcard in the cd command it is reasonable to assume that he want to use cd as a filter and not as a directory change.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6950
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *Horst.Epp »

petermad wrote: 2025-04-13, 13:29 UTC How about:
If there is a wildcard in any part of the command - treat it as a filter and don't remove the quotes.

If the user puts a wildcard in the cd command it is reasonable to assume that he want to use cd as a filter and not as a directory change.
Support +
Simple and logical solution.
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *white »

petermad wrote: 2025-04-13, 13:29 UTC If the user puts a wildcard in the cd command it is reasonable to assume that he want to use cd as a filter and not as a directory change.
So, you're suggesting new functionality, incompatible with how it worked up till now and how it is described in the help?
Help wrote: You can make a button to change directories, by specifying cd directory name as the command. You can even choose which files to show, e.g. using the command cd directory\*.txt, ...
User avatar
petermad
Power Member
Power Member
Posts: 15997
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *petermad »

So, you're suggesting new functionality, incompatible with how it worked up till now and how it is described in the help?
You are right - that is not so smart.

Then we are back to your suggestion - but what if there are widcards in the path:

Code: Select all

cd "c:\test*\test 1.*"
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *white »

petermad wrote: 2025-04-13, 15:17 UTC Then we are back to your suggestion - but what if there are widcards in the path:

Code: Select all

cd "c:\test*\test 1.*"
That's an erroneous command and is ignored/does nothing, similar to executing cd test*\
User avatar
petermad
Power Member
Power Member
Posts: 15997
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *petermad »

So your description should maybe be extended with:
4. Wildcards in paths (before any backslash) will be ignored.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
white
Power Member
Power Member
Posts: 5743
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *white »

petermad wrote: 2025-04-13, 16:19 UTC So your description should maybe be extended with:
4. Wildcards in paths (before any backslash) will be ignored.
I deemed that unnecessary. Take for example these commands:
cd c:\test*\test
cd c:\test*\"test"

Both fail and do nothing. So it doesn't matter if "cd c:\test*\test" (with quotes) is internally converted to either one of these commands.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50383
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 11.51] Quotes are removed from first parameter of the cd command

Post by *ghisler(Author) »

I will try to make this work. For now you can use:
cd .\"test 1.*" "test 2.*"

There are quite a few possibilities to take into account.
The following are all valid commands which need to be handled:
cd "test 1.*" "test 2.*"
cd "c:\test\test 1.*" "test 2.*"
cd "\test\test 1.*" "test 2.*"
cd "test\test 1.*" "test 2.*"
cd "test 1.*" test2.*
cd "c:\test\test 1.*" test2.*
cd "\test\test 1.*" test2.*
cd "test\test 1.*" test2.*
cd test1.* "test 2.*"
cd c:\test\test1.* "test 2.*"
cd \test\test1.* "test 2.*"
cd test\test1.* "test 2.*"
The same with UNC paths like \\server\share
The various file URLs supported by the cd command on the command line:
file:///c:/test/
file:///c|/test/
file:///localhost/c:/test/
file:///localhost/c|/test/
file:///server/share/dir
and the same with URL-encoded characters like " "->"%20" and with 2 or 4 forward slashes.

Wildcards in the path part like cd c:\test*\test are not supported because they are ambiguous, e.g. when there is more than one path matching the pattern:
c:\test1\
and
c:\test2\
Author of Total Commander
https://www.ghisler.com
Post Reply