Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Can alias pass parameters to for command?

Apr
7
0
alias a=echo %*
It work.
>a 1 2 3
1 2 3

alias b=`for %f in (%*) echo %f`
It doesn't work.
>b 1 2 3

output nothing.
 
I'm not sure exactly what's going on here, but it has something to do with the parsing of parentheses:

Code:
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:\>

But the help file only describes %$, not %*. I'm guessing %* is a spillover from batch files. If it works with aliases, it's only by accident. Anyway, that's my guess.
 
Back
Top
[FOX] Ultimate Translator
Translate