Quote inserted filenames with commas, equals, etc.

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
ingenuus
Junior Member
Junior Member
Posts: 12
Joined: 2004-11-24, 23:27 UTC

Quote inserted filenames with commas, equals, etc.

Post by *ingenuus »

When I press Ctrl+Enter on a file or directory name with a space in it, the name is properly double quoted on the command line, but if the name contains some other characters, like a comma, then the name is not quoted.

The problem is that batch files consider a comma (and equals and perhaps other characters) to signify the start of a new parameter.

So, given the batch file "comma_test.bat":
-------------
@echo off
echo * = %*
echo 1 = %1
echo 2 = %2
pause
-------------

Executing it on a directory named "A,B" placed on the command line with Ctrl+Enter results in:

comma_test.bat A,B
-------------
* = A,B
1 = A
2 = B
Press any key to continue . . .
-------------

comma_test.bat A=B
-------------
* = A=B
1 = A
2 = B
Press any key to continue . . .
-------------

Can this please be fixed so that Total Commander double quotes any filenames or directories with such characters?

Thank you!
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

This problem exists in other places too, e.g. in buttonbar button parameters.

Perhaps some INI key with list of filename characters that should trigger name quoting would solve it... if it could be added to TC.
ingenuus
Junior Member
Junior Member
Posts: 12
Joined: 2004-11-24, 23:27 UTC

Post by *ingenuus »

Good idea, MVV. Thanks for chiming in. :) Based upon my test below, it looks like equals, semi-colon, and comma (=;,) are all considered parameter dividers and they are eliminated in cmd parsing:

comma_test.bat X`~!@#$%^*()-+_={}[];:',./\?X
* = X`~!@#$%*()-+_={}[];:',./\?X
0 = comma_test.bat
1 = X`~!@#$%*()-+_
2 = {}[]
3 = :'
4 = ./\?X
5 =

The standard I/O flow characters should also be double quoted if they are in a filename (e.g. ampersands are fairly common): <>&|

So, the default for the INI setting should probably be:

=;,<>&|

(plus space, of course)

I'm not sure about unicode. fwiw, I haven't found harm in excessive quoting, just in deficient quoting. imho, this almost qualifies as a bug, but it has lasted so long in tcmd.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Excessive quoting is only harmful for %S and %P%S parameters where selected files are put onto command line...
ingenuus
Junior Member
Junior Member
Posts: 12
Joined: 2004-11-24, 23:27 UTC

Post by *ingenuus »

Right, you wouldn't want the quotes to surround the whole list of filenames, but you would want each path/filename to be properly quoted if they include commas, equals, semicolons, ampersands, etc.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

No, I mean that quotes may reduce number of filenames that fit into the command line.
ingenuus
Junior Member
Junior Member
Posts: 12
Joined: 2004-11-24, 23:27 UTC

Post by *ingenuus »

Haha, you're right!
Post Reply