- Apr
- 23
- 0
alias a=echo %*It work.
>a 1 2 31 2 3
alias b=`for %f in (%*) echo %f`It doesn't work.
>b 1 2 3output nothing.
Last edited:
By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!alias a=echo %*>a 1 2 3alias b=`for %f in (%*) echo %f`>b 1 2 3Oh yes. It work. Thank you!Try it with %$ instead of %*.
C:\>alias b=`echo ( %* )`
C:\>b foo bar fum
( ) foo bar fum
C:\>alias b=`echo ( %$ )`
C:\>b foo bar fum
( foo bar fum )
C:\>
alias ta=`echo %* tail string`Instead, it showshead string tail string
tail string head string
alias ta=`echo %$ tail string` can correctly display. In other words, alias completely treats %* as non-existent.head string tail string
Aliases can use command line parameters or parameters like those in batch files.
%$ the complete command tail, modified by SHIFT
%* the complete command tail, unmodified by SHIFT
@echo off
setlocal
alias test1=`echo "%$"`
alias test2=`echo "%*"`
echo These two aliases look similar, but they do very different things.
echo TEST1 echos ITS OWN parameters, in quotes:
echo.
test1 One two three
echo.
echo But TEST2 echos any BATCH FILE'S parameters, in quotes, followed
echo by its own, if any:
echo.
test2 One two three
echo.
echo Try calling this batch files with different parameters to see how
echo this works.
echo.
endlocal
vars one two, with three spaces separating the two arguments. %$ All arguments on command line (as per TCC) .............. one two
%$ All arguments on command line (as per TCC) ASCII ........ 111 110 101 32 116 119 111
%* Complete command tail ................................... one two
%* Complete command tail (all characters) ASCII ............ 111 110 101 32 32 32 116 119 111
vars a,b. In one case, commas are stripped and replaced by spaces. As in the above example, %* returns the command tail exactly as the user entered it. %$ All arguments on command line (as per TCC) .............. a b
%$ All arguments on command line (as per TCC) ASCII ........ 97 32 98
%* Complete command tail ................................... a,b
%* Complete command tail (all characters) ASCII ............ 97 44 98
one, ,two, then %$ is one two, and %* is one, ,two.