Welcome!

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

SignUp Now!

Parameter %$ Different in Aliases and BTMa

Jun
552
4
Is this WAD? With aliases, the parameter %$ is passed exactly as is. In a batch file, however, some processing is done. In particular, commas become spaces.

Code:
TCC(27.01.24): C:\temp>alias argalias
echo Arguments = %$

TCC(27.01.24): C:\temp>argalias $1,200
Arguments = $1,200

TCC(27.01.24): C:\temp>type argbtm.btm
echo Arguments = %$

TCC(27.01.24): C:\temp>argbtm $1,200
Arguments = $1 200
 
Two more questions.
  1. Why is a comma not an argument separator in an alias?
  2. Is there any way with batch files to gain access to the entire command tail as entered? This is what I thought %$ meant.
As a workaround, I created a two-command alias wrapper for my batch file. The first command saved %$ to an environment variable, which the batch file could then use when called as the second command. I was trying to process numerical command-line arguments containing comma separators by removing the commas (and dollar signs, which I could do without any problem).
 
If you really want to see everything, you can examine the CMDLINE2 environment variable. But be warned, it really does contain everything everything. Multiple commands, redirection operators, variable references — everything.
 
If I reference %cmdline2 in a batch file, the task hangs.

It looks as though I can use %@word[1-,%cmdline] to get the command tail as entered.
 

Similar threads

Back
Top