Quotes surrounding %P/%T params if toolbar button is a .EXE

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

Post Reply
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Quotes surrounding %P/%T params if toolbar button is a .EXE

Post by *gdpr deleted 6 »

NOTE: The problem only occurs if an .EXE file are used as toolbar button command.
Batch files as as toolbar button commands do NOT seem to be affected by the problem i describe here.

I could verify the problem with both x86 and x64 versions of TC8.51a.

The problem can be observed when using either %P or %T as part of toolbar button parameters. In my following explanation i use %T, but i tested %P as well - with the same results.


Problem scenario

I want to use a toolbar button command with the two parameters

Code: Select all

%T %N
Note the white-space there. The intention is to have two separate parameters (and not a single combined %T%N parameter).

Now, this works fine as long as the target path does not contain white-spaces.
But if the target path contains white-spaces, TC does not automatically use quotes for %T and i would need to add those quotes like this:

Code: Select all

"%T" %N
This all is fine and works as expected if the toolbar button command is a batch file.

However, when using an .EXE executable as the toolbar button's command, this will not result in two parameters passed to the executable.
Instead, only an incorrect single argument is passed, which looks like:

Code: Select all

x:\123 456" somefile.txt
(the current target path being "x:\123 456" and the file name under the cursor being "somefile.txt")


Note the single quote mark in the argument string.

As it seems, TC stumbles during assembling/passing the argument string when starting the .EXE in a new process.

I am not sure if this issue has been reported already. There are quite a few forum posts about handling of quote marks with regard to toolbar button parameters, but none of them seem to address this particular issue which only occurs when .EXE files are being used as toolbar button commands.


FYI

I used a very, very primitive C#/.NET console app to verify this unexpected behavior. Its code is merely:

Code: Select all

static void Main(string[] args)
{
	Console.Out.WriteLine("args.Length = " + args.Length);
	Console.Out.WriteLine();
	foreach (string s in args)
		Console.Out.WriteLine(s);

	Console.In.Read();
}
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 try "%T." instead of "%T" ? %T has a trailing backslash, which may be causing a problem.
Author of Total Commander
https://www.ghisler.com
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

"%T." is indeed a workaround.
In my case "%T\" also seems to be a working workaround.

Actually, as it seems any character placed directly after %T makes the command line parameters behave; for example "%Td" also suppresses the problem (although not really being useful as a workaround ;) ).

While i still consider this being a bug, i leave it to you to prioritize it. Personally i am okay with the workaround, although i wonder how many other people will/did encounter this issue and scratch their heads over how to solve it...
User avatar
Hacker
Moderator
Moderator
Posts: 13142
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

elgonzo,
If you use "%T" then it translates into "x:\123 456\" so as I understand it the second quote is escaped by the backslash, so you need to escape the backslash by a second backslash, thus "%T\" should be the correct solution.
Unless I am wrong. :-D But it works fine. ;)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

Hacker wrote:elgonzo,
If you use "%T" then it translates into "x:\123 456" so as I understand it the second quote is escaped by the backslash, so you need to escape the backslash by a second backslash, thus "%T" should be the correct solution.
Unless I am wrong. :-D But it works fine. ;)

Roman
Yes, i guess so too; somewhere internally TC tries to 'unescape' the trailing backslash character... (Just for fun, try 'escaping' the backslash character added to the param string like "%T\" and the problem would appear again :) )
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Post by *gdpr deleted 6 »

FYI: The issue is not strictly related to the usage of %P or %T (as suggested by my topic tile).
Replacing %T with a literal path "x:\123456\" -- with quote marks and a trailing backspace -- also reproduces the problem.
Post Reply