Page 1 of 1

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

Posted: 2025-04-10, 19:15 UTC
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.

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

Posted: 2025-04-10, 19:23 UTC
by petermad
Confirmed!

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

Posted: 2025-04-13, 08:42 UTC
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. :(

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

Posted: 2025-04-13, 12:10 UTC
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.*"

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

Posted: 2025-04-13, 13:29 UTC
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.

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

Posted: 2025-04-13, 13:35 UTC
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.

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

Posted: 2025-04-13, 14:11 UTC
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, ...

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

Posted: 2025-04-13, 15:17 UTC
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.*"

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

Posted: 2025-04-13, 15:42 UTC
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*\

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

Posted: 2025-04-13, 16:19 UTC
by petermad
So your description should maybe be extended with:
4. Wildcards in paths (before any backslash) will be ignored.

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

Posted: 2025-04-13, 18:43 UTC
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.

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

Posted: 2025-04-14, 08:25 UTC
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\