[11.03] Folder(name) + [Shift+Enter] = problem...

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
MaxX
Power Member
Power Member
Posts: 1039
Joined: 2012-03-23, 18:15 UTC
Location: UA

[11.03] Folder(name) + [Shift+Enter] = problem...

Post by *MaxX »

What to do:

1. Just place any CLI prorgam into folder without spaces WITH "(" and ")", e.g.: D:\WorkDir\TC_WCX_AudioConverter_0992a_Orig(OLD)\faac.exe
2. Then try Shift+Enter on it.
3. Get an error, that "D:\WorkDir\TC_WCX_AudioConverter_0992a_Orig" is not a valid executable...

I still can launch "faac.exe" via regular Enter or type "cmd" to command line and launch my exe from there.

If i add a space or "&" to the folder's name, it helps and I can launch my "faac.exe" via Shift+Enter.

W10 x64, both TC 11.03 32 and 64 bits.
Ukrainian Total Commander Translator. Feedback and discuss.
User avatar
white
Power Member
Power Member
Posts: 4652
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *white »

Confirmed.

You can also try it with a batch file containing "@echo test" instead of faac.exe.
The same problem occurs when the folder name contains a ^ character and no spaces or &.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48195
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *ghisler(Author) »

TC adds double quotes when the name contains certain characters like spaces or &. I'm not aware of any problems with braces in names. Is this really a problem? Why?
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4652
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *white »

ghisler(Author) wrote: 2024-03-19, 08:12 UTC I'm not aware of any problems with braces in names. Is this really a problem? Why?
Why is it not a problem?
  1. Create a batch file test.cmd with the command: @echo test
  2. Put test.cmd in a folder named "(test)" or "test^1"
  3. Pressing Enter on test.cmd works OK
  4. Pressing Shift+Enter does not work OK. (It does work if you add a space to the folder name or filename)
User avatar
MaxX
Power Member
Power Member
Posts: 1039
Joined: 2012-03-23, 18:15 UTC
Location: UA

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *MaxX »

That is definitely a problem. I can't use my CLI prorgam from there.
The easiest solution is just using double quotes for ANY path names. That can fix any problem. No need to find all problematic characters individually.

P.S.
I also remember my old Win XP with "D&S" folder (renamed from "Documents and Settings" to avoid spaces in the paths) and the same problems there. Unfortunately, I didn't know, that the problem was in TC.
This bug really looks the same now.
Ukrainian Total Commander Translator. Feedback and discuss.
User avatar
MVV
Power Member
Power Member
Posts: 8704
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *MVV »

The problem is that cmd.exe parses its /c command just like it parses commands typed into its console, or batch file lines, and there are a bunch of special characters in cmd.exe commands syntax, some of them like braces, ^, & are valid in filenames and must be quoted to avoid special processing. I think it would't be a problem to always quote paths when Shift+Enter used.

When one does Shift+Enter on e.g. C:\(test)\test.bat, TC calls noclose.exe:

Code: Select all

C:\TOTALCMD\noclose.exe C:\(test)\test.bat
And noclose.exe then starts cmd.exe:

Code: Select all

cmd.exe /K "C:\(test)\test.bat"
But cmd.exe in Windows NT removes OUTER quotes from command passed after /C or /K and that causes file path to become unquoted (this causes lots of problems, e.g. when you pass a quoted path to a program and a quoted argument for it) when cmd executes it, you can try executing following command in cmd interactively and it will fail:

Code: Select all

> C:\(test)\test.bat
So, to avoid this stupid cmd.exe behaviour the command line passed to it should be always quoted, even if it already contains quoted path to a program or batch file:

Code: Select all

cmd.exe /K ""C:\(test)\test.bat""

Since this problem affects noclose.exe and not TOTALCMD.exe, it is possible to replace noclose.exe with one that doesn't have this problem, e.g. with this one.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48195
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *ghisler(Author) »

But cmd.exe in Windows NT removes OUTER quotes from command passed after /C or /K and that causes file path to become unquoted
Interesting, I have never heard of that problem. I guess that it would be better to add the extra quotes in noclose.exe than in TC, what do you think?
Author of Total Commander
https://www.ghisler.com
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6524
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *Horst.Epp »

ghisler(Author) wrote: 2024-05-31, 14:53 UTC
But cmd.exe in Windows NT removes OUTER quotes from command passed after /C or /K and that causes file path to become unquoted
Interesting, I have never heard of that problem. I guess that it would be better to add the extra quotes in noclose.exe than in TC, what do you think?
Yes, that is what MVV's suggested link does.
Of course getting a modified version from TC would be better.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3672)
TC 11.03 x64 / x86
Everything 1.5.0.1378a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.78
QAP 11.6.3.3 x64
User avatar
white
Power Member
Power Member
Posts: 4652
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [11.03] Folder(name) + [Shift+Enter] = problem...

Post by *white »

ghisler(Author) wrote: 2024-05-31, 14:53 UTC
But cmd.exe in Windows NT removes OUTER quotes from command passed after /C or /K and that causes file path to become unquoted
Interesting, I have never heard of that problem.
Really?
cmd | Microsoft Learn wrote: If you specify /c or /k, the cmd processes, the remainder of <string>, and the quotation marks are preserved only if all of the following conditions are met:
  • You don't also use /s.
  • You use exactly one set of quotation marks.
  • You don't use any special characters within the quotation marks (for example: & < > ( ) @ ^ | ).
  • You use one or more white-space characters within the quotation marks.
  • The <string> within quotation marks is the name of an executable file.
If the previous conditions aren't met, <string> is processed by examining the first character to verify whether it's an opening quotation mark. If the first character is an opening quotation mark, it's stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.
You never read this?
ghisler(Author) wrote: 2024-05-31, 14:53 UTC I guess that it would be better to add the extra quotes in noclose.exe than in TC, what do you think?
I tend towards that solution. That way noclose.exe could be substituted by programs that are not similar to cmd and don't behave like cmd.
This also maintains compatibility. People may already use a custom noclose.exe that already adds extra quotes.

If, on the other hand, you want to fix the issue also for noclose.exe replacements that work the same way as noclose.exe (that is launch cmd /k without adding extra quotes), then changing TC is better.

If it comes to show that people need it the other way around, an option could be added to TC to configure whether TC itself adds extra quotes.
Post Reply