Parameter %\$ Different in Aliases and BTMa

Jay Sage

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``````

rconn

WAD - a comma is an argument separator in batch files, and it is converted to a space.

Jay Sage

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).

Charles Dye

Super Moderator
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.

Jay Sage

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.

Replies
14
Views
453
Replies
6
Views
465
Replies
2
Views
653
Replies
2
Views
645
Replies
3
Views
817
Replies
2
Views
1K
Replies
14
Views
2K
Replies
0
Views
842
Replies
4
Views
1K
Replies
4
Views
1K
Replies
3
Views
1K
Replies
4
Views
1K
Replies
1
Views
1K
Replies
1
Views
2K
Replies
2
Views
3K
Replies
7
Views
1K
Replies
7
Views
4K
Replies
2
Views
827
Replies
11
Views
2K
Replies
6
Views
2K
Replies
2
Views
879
Replies
2
Views
920
Replies
3
Views
2K
Replies
8
Views
2K
Replies
1
Views
2K
Replies
1
Views
1K
Replies
8
Views
2K
Replies
1
Views
1K
Replies
2
Views
2K
Replies
27
Views
5K
Replies
2
Views
2K
Replies
3
Views
2K
Replies
6
Views
3K
Replies
3
Views
4K
Replies
3
Views
2K
C
Replies
5
Views
3K
Replies
20
Views
8K
Replies
1
Views
3K
Replies
1
Views
3K
Replies
1
Views
3K
Replies
8
Views
5K
Replies
28
Views
812
Replies
1
Views
363
Replies
2
Views
949
Replies
2
Views
1K
Replies
1
Views
950
Replies
3
Views
1K
Replies
4
Views
1K
Replies
8
Views
2K
Documentation Aliases Overview
Replies
3
Views
1K