1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Batchparameter containing equal sign

Discussion in 'Support' started by ente59, Sep 15, 2008.

  1. ente59

    Joined:
    Sep 15, 2008
    Messages:
    5
    Likes Received:
    0
    Hello,

    til today I'm using 4NT 4.01 and I test TCC LE 9,02.152 version!

    I think I found a bug or an incompatability to 4NT version!

    I cannot call a batch with equal sign in a parameter!

    for example:

    ****** testbatch.btm ********
    @echo off
    echo count:%#:
    echo all:%$:
    echo 1:%1:
    echo 2:%2:
    echo 3:%3:
    echo 4:%4:
    ****** testbatch.btm ********

    calling testbatch with the following cal
    testbatch a=1 "b=2" `c=3`
    will produce the following output

    count:4:
    all:a 1 "b=2" c=3:
    1:a:
    2:1:
    3:"b=2":
    4:c=3:

    Why do I have to quote the parameters with backticks?
    It's inkomaptibel to the 4NT version!

    How can I avoid this needed quoting?

    Can anyone give me a hint!

    best regards

    ente59
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    The behavior was deliberately changed, for compatibility with CMD.EXE. (This is often the reason when some sensible behavior is replaced with a peculiar one....)
     
  3. ente59

    Joined:
    Sep 15, 2008
    Messages:
    5
    Likes Received:
    0
    I don't understand this, cause with CMD.EXE all works as expected (the same as with 4nt)

    I renamed testbacht.btm to testbatch.bat

    I call testbatch with the following call
    testbatch a=1 "b=2" `c=3`
    will produce the following output

    Y:\cmd>ver
    Microsoft Windows XP [Version 5.1.2600]
    Y:\cmd>testbatch a=1 b=2 c=3
    count:3:
    all:a=1 b=2 c=3:
    1:a=1:
    2:b=2:
    3:c=3:
    4::
    Y:\cmd>

    any comments?

    best regards

    ente59
     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ente59 wrote:
    | ---Quote (Originally by Charles Dye)---
    | The behavior was deliberately changed, for compatibility with
    | CMD.EXE. (This is often the reason when some sensible behavior is
    | replaced with a peculiar one....) ---End Quote---
    |
    | I don't understand this, cause with CMD.EXE all works as expected
    | (the same as with 4nt)
    | ...
    | any comments?

    I never use CMD, so I hate such changes. However, the name CMD.EXE refers to
    many different versions of that program. It is possible that the one which
    changed is in a later version of WinXP than you use (are you on SP3?), or it
    affects only Vista. IIRC the change was made in 4NT 8 already (I may be
    wrong about that). There were numerous messages in the old NG about it.
    --
    Steve
     
  5. ente59

    Joined:
    Sep 15, 2008
    Messages:
    5
    Likes Received:
    0
    We are still on WinXP SP2 with all MS patches installed
    my cmd.exe ist dated the following
    4.08.2004 1:57 401.408 cmd.exe

    So perhaps this "old" change for cmd.exe was not correct!

    What can I do to get the correct (expected) behaviour!

    best regards

    ente59
     
  6. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,374
    Likes Received:
    40
    It's very strange that your CMD.EXE seems to support %# and %$....

    Here, using Windows XP SP3, I get:

    Code:
    c:\>type testbatch.bat
    @echo off
    echo count:%#:
    echo all:%$:
    echo 1:%1:
    echo 2:%2:
    echo 3:%3:
    echo 4:%4:
     
    c:\>ver
     
    Microsoft Windows XP [Version 5.1.2600]
     
    c:\>testbatch a=1 b=2 c=3
    count:
    all:
    1:a:
    2:1:
    3:b:
    4:2:
     
    c:\>
    
     
  7. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    ente59 wrote:
    | ---Quote (Originally by Steve Fábián)---
    | I never use CMD, so I hate such changes. However, the name CMD.EXE
    | refers to many different versions of that program. It is possible
    | that the one which changed is in a later version of WinXP than you
    | use (are you on SP3?), or it affects only Vista. IIRC the change was
    | made in 4NT 8 already (I may be wrong about that). There were
    | numerous messages in the old NG about it. ---End Quote---
    |
    | We are still on WinXP SP2 with all MS patches installed
    | my cmd.exe ist dated the following
    | 4.08.2004 1:57 401.408 cmd.exe
    |
    | So perhaps this "old" change for cmd.exe was not correct!
    |
    | What can I do to get the correct (expected) behaviour!

    Ask MS to change their code, and JPsoft will do likewise.
    --
    Steve
     
  8. K_Meinhard

    Joined:
    May 20, 2008
    Messages:
    312
    Likes Received:
    0
    Steve FXbiXn wrote:



    Don't you think that Rex should answer this question?

    Mit freundlichem Gruß,

    Klaus Meinhard
     
  9. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,092
    Likes Received:
    85
    ente59 wrote:

    Note that CMD does not support the %# and %$ variables, so if you're
    getting a value from them you're not really running CMD.

    .BAT files are executed by the Windows COMMAND.COM (which is a stub that
    does a few things internally but calls CMD or TCC to do the bulk of its
    work).

    Try renaming your test file to TESTBATCH.CMD, run it in TCC, then type
    "CMD" at the TCC command line and run it again.

    Here I see:

    TCC:

    [C:\TakeCommand10]testbatch a=1 "b=2" `c=3`
    count:4:
    all:a 1 "b=2" c=3:
    1:a:
    2:1:
    3:"b=2":
    4:c=3:

    CMD:

    C:\TakeCommand10>testbatch a=1 "b=2" `c=3`
    count:

    all:

    1:a:

    2:1:

    3:"b=2":

    4:`c:


    The output is the same with the exception that CMD doesn't recognize the
    single back quote for #4.

    Rex Conn
    JP Software
     
  10. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    K_Meinhard wrote:
    | Steve FXbiXn wrote:
    |
    |
    |
    | ---Quote---
    ||| What can I do to get the correct (expected) behaviour!
    | ---End Quote---
    |
    |
    | ---Quote---
    || Ask MS to change their code, and JPsoft will do likewise.
    | ---End Quote---
    | Don't you think that Rex should answer this question?

    The original question was asked and answered by Rex several times in the
    past. Charles Dye, responding to the original post, explained why the
    behavior changed. The question in the above quote is polemical - when a
    program behaves as intended by its author, its behavior is correct by
    definition, regardless of what any one user expects (or any million users).
    Short of regresssing the change - which would be done if Microsoft regressed
    their change - there is no method to achieve the older behavior with the
    newer software. This is the answer Rex is most likely to give.

    IIRC you, Klaus, also answered questions in the past stating that there is
    no method to achieve certain specific goals.
    --
    Steve
     

Share This Page