Discarding unreferenced alias parameters

nchernoff

Administrator
Staff member
May 16, 2008
42
2
#1
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:\>