TCs command line: Parsing TAB chars problem ?

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
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

TCs command line: Parsing TAB chars problem ?

Post by *MarcinW »

I'm not quite sure if this should be reported as a bug or a suggestion, but I decided to place it here.

Tested with TC 9.0 beta3 32-bit:
1) I assume here, that "c:\windows" folder exists.
2) Open Notepad.exe and write the following text: cd c:\windows (important: place only one TAB character, not SPACES, between "cd" and "c:\windows").
3) Copy this text to the clipboard, paste to the TC's command line and try to execute. A "File not found!" error appears.

After pasting this text to a cmd.exe window, command is executed properly.

I found this problem when pasting some commands from a formatted TXT or PDF file.

Solution: replace all TAB chars with spaces before parsing the command line.

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

Post by *MVV »

It is not a bug definitely because space is a delimiter in Windows, not tab, and it will not work in most programs with tabs, e.g. in Win+R dialog.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6976
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

Like MVV already said its not a bug.
Also its no suggestion because no one (except you) uses tabs in Windows command lines.
User avatar
Dalai
Power Member
Power Member
Posts: 9968
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

It's always a good idea to paste some command taken from unknown and/or unreliable sources into an editor before pasting them into the command line. Web sites can manipulate clipboard contents so you may not necessarily be copying the contents into the clipboard you think you are copying (the text you marked). See for example this thread on StackOverflow.

Yes, I know that web sites are not PDFs or some documents but the same principle applies. PDFs may even contain script elements, too.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

MVV wrote:It is not a bug definitely because space is a delimiter in Windows, not tab, and it will not work in most programs with tabs, e.g. in Win+R dialog.
Horst.Epp wrote:[...] no one (except you) uses tabs in Windows command lines.
Just for compatibility reasons, TC's command line should be able to execute commands, that can be executed in a console window (cmd.exe). Please note, that cmd.exe CAN execute BAT scripts with TABs. After pasting some command from a BAT file to the TC's command line, it would be nice to have this command executed.

Or discussion took at least 10 minutes, but the issue can be handled in one minute ;)

Code: Select all

for I:=1 to Length(CommandLine) do
if CommandLine[I] = #9 then
  CommandLine[I]:=' ';
Regards
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50550
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Indeed tabs are not supported in cd command in command line, since you can't enter them there anyway. TC expects spaces as delimiters.
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 »

That's just the point - TC currently doesn't expect TABs as delimiters, but TABs can be pasted from a BAT file.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Are there people that indent command arguments with tabs in bat files? Oo
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Since Microsoft implemented TAB handling in cmd.exe, it's possible that TABs can be found in some bat files provided by Microsoft.
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

MVV wrote:Are there people that indent command arguments with tabs in bat files? Oo
Yes. (In Batch file, but not for command line itself)



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

Post by *MVV »

I mean, do you indent not commands itself but command parameters? The former one I can understand but not the latter one...

Code: Select all

        cd %TEMP%

Code: Select all

cd     %TEMP
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

I have used tabs often in batch

Code: Select all

 
for x in (y) do (
             Echo x
             Copy x C:\temp
)

Echo abc            > x
Echo defgh ikl mno >> x


and had never an issue with that.

But I would never use tabs in an command line itself.
And I would not expect an file manager to be that smart to saves me.
But it would not hurt either.
OTOH there are more important things to work on.



 
User avatar
wanderer
Power Member
Power Member
Posts: 1640
Joined: 2003-03-28, 14:35 UTC
Location: Sol

Post by *wanderer »

MarcinW wrote:That's just the point - TC currently doesn't expect TABs as delimiters, but TABs can be pasted from a BAT file.
IMHO, since tabs are supported in windows command line, they should also be supported in TC. They may not be directly insertable but since one can paste them from a batch file (in which they are supported), they should also work normally in TC.

TC could just replace each TAB character with a single space just before pasting or executing the command-line statement (whichever one is easier).
- Wanderer -

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Normally using latest TC on:
x32: WinXPx32 SP3 (very rarely nowadays).
x64: Clients/Servers - Win10/Win11 and Win2K16 to Win2K22, mainly Win10 though.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Stefan2,
Do you know that echo with a lot of trailing spaces (even a single space) before redirection symbol writes these trailing spaces to a file?
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

MVV wrote:Stefan2,
Do you know that echo with a lot of trailing spaces (even a single space) before redirection symbol writes these trailing spaces to a file?
No :?

I have seen suggests to invert that command line, but never needed.

I never have seen an issue with my adjusted commands?


 
Post Reply