[TC11.01] Invalid variable substitution (%A1:~1,-1)

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

Moderators: white, Hacker, petermad, Stefan2

Post Reply
andry81
Junior Member
Junior Member
Posts: 97
Joined: 2018-11-22, 19:17 UTC

[TC11.01] Invalid variable substitution (%A1:~1,-1)

Post by *andry81 »

I am trying to pass environment variable together with the user command parameter:

Code: Select all

[em_test]
cmd=em_test_impl "%COMSPEC%"
param=%A1

[em_test_impl]
cmd=cmd.exe
param=/k echo.%A1:~1,-1\%A2
Button:

Code: Select all

TOTALCMD#BAR#DATA
em_test
123 456
C:\totalcmd\TOTALCMD.EXE,3


0
-1
Result:
C:\WINDOWS\system32\cmd.exe" \123
Expectation:
C:\WINDOWS\system32\cmd.exe\123
I need quotes because the environment variable value can have has spaces and I can not use it without quotes:

Code: Select all

[em_test]
cmd=em_test_impl %CommonProgramFiles%
param=%A1

[em_test_impl]
cmd=cmd.exe
param=/k echo.%A1\%A2
Result:
C:\Program\Files\Common
I know I can pass the environment variable in the "param" key as "%%COMSPEC%%", but it will leave the expansion to the "cmd.exe". I want to expand it by the Total Commander.

Is there another way to use both variables at the same time?
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC11.01] Invalid variable substitution (%A1:~1,-1)

Post by *white »

2andry81
I confirm that the form :~start,length doesn't seem to work well with the %A1, %A2, etc. parameter. Perhaps due to the number behind the A because it seems to work with %A.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC11.01] Invalid variable substitution (%A1:~1,-1)

Post by *ghisler(Author) »

I will check it. I never tried the :~ notation with multi-character placeholders like %A1.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC11.01] Invalid variable substitution (%A1:~1,-1)

Post by *white »

Moderator message from: white » 2023-09-20, 19:58 UTC

TOPPER808 wrote:2023-09-20, 17:23 UTC https://www.ghisler.ch/board/app.php/smartfeed/feed?u=514314&...
2TOPPER808
That's not how smartfeed urls work. You don't post them in a forum post, you use them in your newsfeed reader program.

2 posts deleted from this thread.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC11.01] Invalid variable substitution (%A1:~1,-1)

Post by *ghisler(Author) »

This should be fixed in Total Commander 11.02 RC1, please test it!
21.09.23 Fixed: Internal commands: Parameters %A1, %A2 etc. incorrectly handled substring fields like %A1:~1,-1 (32/64)
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC11.01] Invalid variable substitution (%A1:~1,-1)

Post by *white »

Tested OK using TC 11.02rc1.

Moderator message from: white » 2023-10-06, 13:39 UTC

Moved to Fixed bugs.
Post Reply