+-Spaces in command line, between parameters

Bug reports will be moved here when the described bug has been fixed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

+-Spaces in command line, between parameters

Post by *MarcinW »

This is not a problem with spaces in file names (as discussed somewhere here), but with spaces in the command string.


Tested with TC 8.50 Beta 13. Commands in red lines don't work. Launch in the command line:

cd C:\WINDOWS\NOTEPAD.EXE
cd "C:\WINDOWS\NOTEPAD.EXE"
cd C:\WINDOWS\NOTEPAD.EXE (2 spaces between cd and file name, which not visible here)
cd "C:\WINDOWS\NOTEPAD.EXE" (2 spaces between cd and file name, which not visible here)

When inside C:\WINDOWS directory:

cd NOTEPAD.EXE
cd "NOTEPAD.EXE"
cd NOTEPAD.EXE (2 spaces between cd and file name, which not visible here)
cd "NOTEPAD.EXE" (2 spaces between cd and file name, which not visible here)


I suppose that TC could safely ignore additional spaces between command line parameters. Such spaces are sometimes inserted when pasting command parts from some text file or a console window.

Regards
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Interesting. It is much easier to use same command line parsing algorithm for all places... Usually I use special function GetCommandLineString everywhere to get next parameter and move pointer, so number of spaces or quotes doesn't matter...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Spaces at the beginning are not ignored, so you can enter paths starting with a space. Of course it makes little sense to ignore them also when they are in front of " or a drive letter, but there are too many such cases to handle them all. The user will see his error and retry with the correct name.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

ghisler,
I think user can use explicit quoting if he needs to enter folder with name starting with space... Such names are quite rare and unusual.
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

I appreciate this function of TC, when cd command tries to fit path+filename with spaces, but without doublequotes. I use this function quite often.

This function would be even better, when ignoring spaces when, as you said, it is clear that these spaces are meaningless, i.e. before drive letter, " or \\. This would solve problems shown in 1-st and 3-rd red line.

Besides, to make it better one more time, TC could also try go to "NOTEPAD.EXE", when going to " NOTEPAD.EXE" (with some spaces at the beginning) failed. This would also solve problem shown in 2-nd red line.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

OK, I have changed this partially now: Leading spaces will be ignored when followed by a double quote ". Otherwise they will be treated as part of the directory name.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Tested with TC 8.50 Beta 14:

cd C:\WINDOWS\NOTEPAD.EXE
cd "C:\WINDOWS\NOTEPAD.EXE"
cd C:\WINDOWS\NOTEPAD.EXE (2 spaces between cd and file name, which not visible here)
cd "C:\WINDOWS\NOTEPAD.EXE" (2 spaces between cd and file name, which not visible here)

When inside C:\WINDOWS directory:

cd NOTEPAD.EXE
cd "NOTEPAD.EXE"
cd NOTEPAD.EXE (2 spaces between cd and file name, which not visible here)
cd "NOTEPAD.EXE" (2 spaces between cd and file name, which not visible here)

As I understand, the red case is by design now.
So can be moved to "fixed".
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, the red case is by design! It allows to launch files with leading spaces without the need to use double quotes.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Thanks! So, as a summary: there is only one thing to improve, that you may consider in the future (as I wrote above): TC could try go to "NOTEPAD.EXE", when going to " NOTEPAD.EXE" (with some spaces at the beginning) failed.

Regards
Post Reply