Welcome!

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

SignUp Now!

Understanding SHIFT

Feb
61
1
The manual states that SHIFT /n also affects the value of %*. I have a case where it doesn't - so I wonder if I misunderstood, if the doc is wrong or the implementation:
Here's testshift.btm:
@echo off
echo [a] *: %*
echo [a] $: %$
shift /1
echo *: %*
echo $: %$


And a sample of running testshift.btm 1 2 3
[a] *: 1 2 3
[a] $: 1 2 3
*: 1 2 3
$: 2 3


%* seems to be not affected.

P.S: TCC 25.00.24 x64 Windows 10 [Version 10.0.18363.657]
 
Where did you see that? I found these.

1583852063975.png


This form of SHIFT also affects the special parameters %n$, %$ and %# (number of command parameters). However, for compatibility with CMD, this form of the SHIFT command does not alter the contents or order of the parameters returned by %*.
 
I think that table is from "Batch File Parameters". The page about SHIFT ends with a remark "This form of SHIFT also affects the special parameters %n$, %$ and %# (number of batch file parameters). " - and if you have glasses and it's too late, you may think that you saw %* in that text. At least that's what happened to me <blush> ;) Sorry for the trouble - all is well!
 
Actually I don't need glasses - the help-file says exactly that!
1584355069460.png


Help>Overview says "Monday, November 11, 20109". So I ran the updater and got a new help-file which does not show the remark about affecting %*.
 

Similar threads

Back
Top