Command tail (%$ / %*) problem

May 30, 2008
80
0
Gerakas, Greece
There seems to be some inconsistency in the way that the two batch file parameters for command tail handle things:

Consider this batch file (cmdtail.btm):

Code:
@echo off
echo Star   -- %*
echo Dollar -- %$
echo 0 : %0
echo 1 : %1
echo 2 : %2
echo 3 : %3
When you run the following command:

Code:
cmdtail alpha beta=gamma
You get the following:

Code:
Star   -- alpha beta=gamma
Dollar -- alpha beta gamma
0 : cmdtail
1 : alpha
2 : beta
3 : gamma
Is this correct behavior? I mean the fact that %$ omits the "="? Are they supposed to be different? Did the behavior change on some version? For reference, the behavior, apart from %$ of course is the same in cmd.exe.

This is a problem that occurred from maven, so it does have real-world significance :)

Perhaps this has been posted before, but I didn't know how to search this. :)
 
May 20, 2008
3,515
4
Elkridge, MD, USA
----- Original Message -----
From: "gschizas" <>
| Is this correct behavior? I mean the fact that *%$* omits the *"="*? Are
they supposed to be different? Did the behavior change on some version? For
reference, the behavior, apart from *%$* of course is the same in cmd.exe.

Yes, several versions ago, the change was made to match a change in
CMD's misbehavior.

| This is a problem that occurred from maven (http://maven.apache.org/), so
it *does* have real-world significance :)

Yes, unfortunately this is a problem for programs that are not designed
for the latest version of CMD.EXE. And no, I am not aware of any
work-arounds, since the same problem would occur with executing the same
batch files with CMD.EXE, you must modify the files themselves.
--
Steve
 

rconn

Administrator
Staff member
May 14, 2008
12,364
150
> Is this correct behavior? I mean the fact that *%$* omits the *"="*?
> Are they supposed to be different? Did the behavior change on some
> version? For reference, the behavior, apart from *%$* of course is the
> same in cmd.exe.

WAD (for compatibility with CMD). I believe that %* was changed a couple of
years ago in v10 to match CMD. %$* matches the actual CMD behavior when
parsing arguments for batch files, which is to consider = as whitespace and
strip it. (As is obvious in the actual argument list your batch file
displays.)


> This is a problem that occurred from maven so it *does* have real-world significance :)

I don't understand this -- since TCC behaves identically to CMD, how does
this cause a problem with maven?

Rex Conn
JP Software
 
May 30, 2008
80
0
Gerakas, Greece
WAD (for compatibility with CMD). I believe that %* was changed a couple of
years ago in v10 to match CMD. %$* matches the actual CMD behavior when
parsing arguments for batch files, which is to consider = as whitespace and
strip it. (As is obvious in the actual argument list your batch file
displays.)

It's all right to strip it, the only problem was that %$ (which doesn't exist on CMD) had a different behavior. %$ does strip the "=", %*, that is CMD compatible, doesn't strip it. I have to admit it makes more sense to me for TCC not to strip the "=" in any case, even though it does split the parameters in a CMD-compatible way. But I guess that could break existing batch files...

I don't understand this -- since TCC behaves identically to CMD, how does
this cause a problem with maven?

Rex Conn
JP Software

Oh, simple. Maven tried to be smart and use %* for CMD and %$ for 4NT (sic) :).

Ok, the resolution to my problem is obvious - change the mvn.bat file to NOT try and be smart and detect 4NT (especially by using if "%@eval[2+2]" == "4"). There are just two parts where mvn.bat tries to be clever (and a part that is really stupid, as it has TWO ENDLOCALs without having two SETLOCALs), I've already fixed the offending part. The other part is the fragment below, but I'm not so sure I need to change it...:

Code:
@REM -- 4NT shell
if "%@eval[2+2]" == "4" goto 4NTCWJars

@REM -- Regular WinNT shell
for %%i in ("%M2_HOME%"\boot\classworlds-*) do set CLASSWORLDS_JAR="%%i"
goto runm2

@REM The 4NT Shell from jp software
:4NTCWJars
for %%i in ("%M2_HOME%\boot\classworlds-*") do set CLASSWORLDS_JAR="%%i"
goto runm2
 
May 30, 2008
80
0
Gerakas, Greece
| This is a problem that occurred from maven, so
it *does* have real-world significance :)

Yes, unfortunately this is a problem for programs that are not designed
for the latest version of CMD.EXE. And no, I am not aware of any
work-arounds, since the same problem would occur with executing the same
batch files with CMD.EXE, you must modify the files themselves.
--
Steve

Actually it does work with the latest (Windows 7) cmd.exe - that was the reason I found the problem. The problem was that it tried to be too smart for its own good and tried to parse 4NT (sic) in a different way than cmd.exe. There is also some code for Win9x in there as well, I guess command.com has a completely different way to parse arguments as well :)
 
WAD (for compatibility with CMD). I believe that %* was changed a couple of years ago in v10 to match CMD. %$* matches the actual CMD behavior when parsing arguments for batch files, which is to consider = as whitespace and strip it.

Is this documented in the Help? If not, I would find it useful if the facts that = is a command separator and %* and %$ differ in this regard was documented in the Help, e.g., on the "Batch File Parameters" page.
 
Similar threads
Thread starter Title Forum Replies Date
Dmitry L. Kobyakov How to? How to remove the record of the old version of the Take Command? Support 9
D Can alias pass parameters to for command? Support 3
samintz How to? Search for %(command) in Help? Support 1
T VIEW only works from command line Support 14
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
GermanDirk How to? EVENTLOG Command with simple User Rights not functional Support 4
Jay Sage Take Command Is Too Fast! Support 4
Jay Sage Comparison of IF with Command Group and IFF Support 6
D Open Windows 10 Photos app from command line Support 11
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
U Can not get/start Take Command gui Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
S Increasing Font Point Size in Command Tabs Support 2
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica Command name mix-up Support 3
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
E How to? Closing desktop created by DESKTOP command Support 10
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
K Take Command fox XP? Support 7
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
fpefpe How to? command echo in title line/bar Support 2
U Command help on file names Support 5
vefatica Command line DO with no closing parenthesis? Support 9
vefatica Command history search is off Support 7
H How to? How can I say "if the command separator is not ~ then setdos /C~" Support 8
N Command execution slows down in TCC Prompt after a while Support 6
R Long commands retrieved from command history have blank line when wrapped Support 20
jpeni Take Command Language Examples Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 26.02.41 Uploaded Support 0
fpefpe winfr command Support 4
Dmitry L. Kobyakov Fixed The SETARRAY /R command works incorrectly with cyrillic files Support 2
M Selecting test "off by one" problem in Take command Support 4
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
R How to? Open Take Command at current folder Support 7
rconn News Take Command / TCC / CMDebug / TCC-RT 26.01.40 uploaded Support 0
C TEE command appending null characters to output Support 6

Similar threads