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

Discarding unreferenced alias parameters

Discussion in 'T&T - Aliases' started by nchernoff, Jun 9, 2008.

  1. nchernoff

    nchernoff Administrator
    Staff Member

    Joined:
    May 16, 2008
    Messages:
    42
    Likes Received:
    2
    Migrated From JP Software Wiki

    When 4NT expands aliases, it appends all unreferenced arguments to the end of the command line:

    Code:
    C:\>alias test=`echo one=%1 %+ echo two=%2 %+ echo three=%3`
    
    C:\>test Alpha Beta Gamma Delta Epsilon
    one=Alpha
    two=Beta
    three=Gamma Delta Epsilon
    
    C:\>
    
    Sometimes this behavior is undesirable, and you would rather just discard all of the unreferenced arguments. One simple way to do this is to end your alias with %+ rem . The REM command will receive all of the excess arguments, and duly ignore them.

    Code:
    C:\>alias test=`echo one=%1 %+ echo two=%2 %+ echo three=%3 %+ rem`
    
    C:\>test Alpha Beta Gamma Delta Epsilon
    one=Alpha
    two=Beta
    three=Gamma
    
    C:\>
    
     

Share This Page