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

WAD Possible Bug in Batch Parameters

Discussion in 'Support' started by Jay Sage, Nov 9, 2014.

  1. Jay Sage

    Joined:
    Jun 2, 2008
    Messages:
    284
    Likes Received:
    1
    The help file says that the special character string %* represents, and I quote: "the complete command tail, unmodified by SHIFT". However, the following batch file

    echo The number of arguments is %#
    echo Command tail is :%$:
    echo Command tail is :%*:​

    when run with the argument "test" (without the quotes) produces the following output:

    echo The number of arguments is %#
    echo Command tail is :%$:
    echo Command tail is :%*:​

    WHOA! That's not what it produces. That's what copying and pasting from the TCMD17 screen produces (another bug?). Here's what I actually see on the screen:

    echo The number of arguments is 1
    echo Command tail is :test:
    echo Command tail is :*:
    So it appears that "%*" is not working. For me, it doesn't seem to be working in version 16 either.

    -- Jay
     
  2. mikea

    Joined:
    Dec 7, 2009
    Messages:
    211
    Likes Received:
    2
    FWIW...I'm still using v.15 -- I'm always slow to update -- and get unexpected results (like yours) with the statement containing %* when I use colons or single quotes (apostrophes, not back-quotes). I get the expected results when I use double quotes. (Talking about what the .btm file echoes to the terminal. I didn't also try copying and pasting from the screen.)
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    Code:
    echo Command tail is :%*:
    That doesn't work in any TCC back to v11. But it does work if you remove the second ':'.

    It also fails with any of these after the '*' ... *, \, !, @, #, $, %%, a-z, A-Z ... but /, (, and ) are OK.

    I didn't try others.
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    Jay, are you sure the copy error wasn't you ... copying the TYPEd file in TCMD? If you copied
    Code:
    echo The number of arguments is 1
    echo Command tail is :test:
    echo Command tail is :*:
    and got
    Code:
    echo The number of arguments is %#
    echo Command tail is :%$:
    echo Command tail is :%*:
    that would be one hell of a bug!
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    %* works fine, provided you don't append a colon. The only valid characters following a %* are a space, tab, ", |, <, >, {, }, (, ), ;, +, =, /, and '. Anything else stops the %* processing. (A colon is a particularly bad choice as a delimiter character, as it has a special meaning as a drive designator.)

    %* is normally used at the end of a command line, or in a command group. What purpose did you have in enclosing it in colons?

    I do not understand what you're saying about the cut & paste.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    Rex, can you tell us exactly what's happening there, and below? Is there some general principle involved?
    Code:
    v:\> echo %*
    ECHO is OFF
    
    v:\> echo :%*:
    :*:
     
  7. Jay Sage

    Joined:
    Jun 2, 2008
    Messages:
    284
    Likes Received:
    1
    Maybe that is what happened. I selected the text in the TCMD window and used Ctrl-C to copy it, but maybe the copy failed, leaving the previous contents of the clipboard unchanged. As I think about it now, what I thought I saw is highly unlikely!

    Rex, I was just trying to test the %* parameter and put some characters around it so I could see if any spaces were introduced. I had tried other characters with the same result. All this started when real code failed to work. That code may have had a command separator after the %* without any spaces.

    A lot of my aliases and batch files are giving me trouble under version 17, and I have been forced to do a lot of editing. Things that worked before, even if they were illegal or discouraged, do not work now. One example is the use of %+ as a configuration-invariant command separator. For years in Z System (ZCPR) in the 8-bit world and in Unix I was used to using the semicolon as a command separator, and I continued to do so in TCC. I have finally bitten the bullet, accepted the default configuration, and converted my alias definitions. I still have to check all the batch files. This is painful, but it had to be done at some point.

    -- Jay
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
    Same thing that has bitten you before - the ':' in a variable name is interpreted as string substitution syntax.
     

Share This Page