lst2str 1.20 bug

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

lst2str 1.20 bug

Post by *Valentino »

2JackFoo
Command line parameters that I use for lst2str are:

Code: Select all

/X:"C:\Program Files\TotalCmd\utils\CmdLineViewer.exe" /L:"%L" /F:%T%M /N:2
As you can see I wrote a small console program (CmdLineViewer.exe) only to track down what's going on. It helped :)

If I select two files (e.g. "a.txt" and "b.txt") in the source pane and cursor in the target pane is at the ".." entry, lst2str receives the following:

Code: Select all

/X:"C:\Program Files\TotalCmd\utils\CmdLineViewer.exe" /L:"C:\DOCUME~1\UserName\LOCALS~1\Temp\CMD29F4.tmp" /F:"C:\Program Files\TotalCmd\utils\" /N:2
and produces the following:

Code: Select all

"C:\Program Files\TotalCmd\utils\a.txt" "C:\Program Files\TotalCmd\utils\b.txt" "C:\Program Files\TotalCmd\utils" /N:2"
but it should produce the following:

Code: Select all

"C:\Program Files\TotalCmd\utils\a.txt" "C:\Program Files\TotalCmd\utils\b.txt"
so this ending:

Code: Select all

"C:\Program Files\TotalCmd\utils" /N:2"
can be called "crap" :)
User avatar
nsp
Power Member
Power Member
Posts: 1913
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: lst2str 1.20 bug

Post by *nsp »

Valentino wrote:2JackFoo
Command line parameters that I use for lst2str are:

Code: Select all

/X:"C:\Program Files\TotalCmd\utils\CmdLineViewer.exe" /L:"%L" /F:%T%M /N:2
As you can see I wrote a small console program (CmdLineViewer.exe) only to track down what's going on. It helped :)
I did the same and is is working fine after re-editing the parameters on my buton definition... but at first try i received an additional quote that changed the command received by lst2str....
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

2nsp
What do you mean by "reediting"? Shoudl I change something?

P.S. This bug is reproduced always. It does not depend whether this is the first try or not :)
User avatar
nsp
Power Member
Power Member
Posts: 1913
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

Valentino wrote:2nsp
What do you mean by "reediting"? Shoudl I change something?
I've forgotten to give you the hint,.... you can move the /N:002 before the /F:xxx

Code: Select all

/X:"list.bat" /L:"%L"  /N:002  /F:%T%M
list.bat is my ComandLister.exe

Code: Select all

@echo %*
pause
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

nsp wrote:
Valentino wrote:2nsp
What do you mean by "reediting"? Shoudl I change something?
I've forgotten to give you the hint,.... you can move the /N:002 before the /F:xxx
Thanks, this helped! But...
1) In readme.txt it's documented that order of command line arguments is not important.
2) This bug is not reproduced if the cursor in the target pane is on the file or folder. The bug is only reproduced if cursor is on "..".
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

I can't reproduce it, no matter what order the prameters are passed in.

[Please note that the T or target pane is the one that is unfocused, i.e. TC's cursor is in the other pane. The same applies to the List, it is the list of files that are selected in the pane where the focus is in.]

Could you desribe _exactly_ what happens, and what triggers it?

Cheers.
User avatar
nsp
Power Member
Power Member
Posts: 1913
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

Valentino wrote: 1) In readme.txt it's documented that order of command line arguments is not important.
2) This bug is not reproduced if the cursor in the target pane is on the file or folder. The bug is only reproduced if cursor is on "..".
I confirm the bug, i think that it is due to the quoting of the /F parameter inside lst2str and it is not a TC bug during the call to it.
......
you can probably do the same using a specific batch script ;)....
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

nsp wrote:I confirm the bug, i think that it is due to the quoting of the /F parameter inside lst2str and it is not a TC bug during the call to it
What do you mean by quoting? Can you type in the exact command that causes the bug.

Thanks.
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

OK, nm. I found the problem, or actually a misuse.

/F:%T%M - TC fills the %T%M with something like [c:\Program Files\foo\] the fact is that you should always inclose the parameters in quotes like you did with /L:"%L".

2Valentino:
Change the command line into /F:"%T%M" and it doesn't matter what order the parameters are in.

Cheers.
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

JackFoo wrote:/F:%T%M - TC fills the %T%M with something like [c:\Program Files\foo\] the fact is that you should always inclose the parameters in quotes like you did with /L:"%L".
No, TC adds quotes itself, see my first post - your app gets quotes. If I put this: /F:"%T%M", TC passes two quotes: /F:""C:\Program Files\and so on"". So try to find the bug in lst2str. BTW, it is not reproduced if target folder does not contain spaces.
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

Before we start arguing, could you try adding quotes and see what happens.

Also could you describe _exactly_ how to reproduce it.

Cheers.
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

JackFoo wrote:Before we start arguing
I even didn't think of this, your util is nice, I still use it :)
JackFoo wrote:could you try adding quotes and see what happens.
I had already done this before writing previous post, it fails. If I add the quotes (i.e. if I use /F:"%T%M" instead of /F:%T%M), TC passes your app the following:

Code: Select all

/X:"C:\Program Files\TotalCmd\utils\CmdLineViewer.exe" /L:"C:\DOCUME~1\UserName\LOCALS~1\Temp\CMD29F4.tmp" /F:""C:\Program Files\TotalCmd\utils"" /N:2
and your app produces the following:

Code: Select all

"C:\Program Files\TotalCmd\utils\a.txt" "C:\Program Files\TotalCmd\utils\b.txt" "C:\Program"
Note that your app still produced 3 args instead of 2, although the result is a little different from the previous case (with /F:%T%M).
JackFoo wrote:Also could you describe _exactly_ how to reproduce it.
I did this in the first post, very detailed explanation. The only thinng that I can add is that both source and target panes contained spaces (C:\Program Files\TotalCmd\utils). And yes, I know that the source pane is where the focus rectangle is located :)
I use WinXP SP2, TC7pb2.
User avatar
JackFoo
Senior Member
Senior Member
Posts: 373
Joined: 2003-02-05, 19:53 UTC
Location: ERROR

Post by *JackFoo »

Something wierd is definitely going on, but the culprit is TC. It's got to do with how TC passes the parameters and handles quotes.

Try compiling this:

Code: Select all

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int i = 0;

	for(; i < argc; i++)
		puts(argv[i]);

	getc(stdin);
	return 0;
}
now place the following in the parameters

Code: Select all

/X:"C:\Program Files\program\dummy.exe" /L:%L /F:%T%M /N:2 /C:1024
and the compiled programs name as the command.

you'll see that when %M is empty TC doesn't quote the strings correctly, worse still is that it tries to 'fix' quotes and does so incorrectly removing them if you placed /F:"%T%M"

So it's got nothing to do with lst2str but congrats on finding a genuine TC bug.

P.S. the bug manifests itself only when the cursor was on the [..] in the target pane.

P.P.S. for the lazy I include the binary (XXE) of the above code if you want to check:

Code: Select all

begin 644 test.7z
hBrewfmQQ++9KMLAKmkA+++++++-y++++++++++3ZFvA+7dOCQ++Lxyk3iyfo
hztE-9oHjTCPp0FZ2+WbzIwrKoFHyba4QUVLq0LegOvHhJ-0S7gdlnwJ58wXf
h6YLyETenKMxm-+a+PndgLgJI-Rmc7l28L7yDIPawNT+YMCAOUFg751Wjc1BV
h8SaHAFb1cU0v5moHxc-4X5pXTfwP5kyoXXZvzw4QquWmoOwbG-ErS2RhNevE
ha6RCEhoinb5IbpiVGDDc1YMd4lvJkRcwP9Ml8UGdcDkf18cG8n26SAqhlJY3
hjy9g2GnFjWxdH4eGnLQUhoOrTg-ebNW5WOSOuarCtTciQtAtBrNL+grd49rK
hiQQKDcj6Q-o7hwG4t0T1clbr0NnxBc25FJsJ0ghXrprh0LpkrwuwcX+NPqoP
hOasR5hZoKns7pQ3w7DFcYsWE4yFWgoB4OBguItdcnzHvwtr2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1129
User avatar
Valentino
Power Member
Power Member
Posts: 709
Joined: 2003-02-07, 00:21 UTC
Location: Ukraine

Post by *Valentino »

2JackFoo
Hmm... Indeed. First I was surprised that my CmdLineViewer.exe (Win32 app) displays different command line than your test.exe (console app). After some investigation, I have to assume that TC handles %T or %M or both differently for console and Win32 applications. I do not know how else to explain that Win32 app gets proper cmd line args, and console app gets them wrong. Since your app is console, you got some mess. Sorry, that I "accused" you :)

Or maybe it's not TC... Then who?.. Who can be between TC and console app? Maybe it's RTL bug?

Christian, do you read this?
Post Reply