How to shift %*?

  • Thread starter Thread starter survivor
  • Start date Start date
S

survivor

I am writing a cmd script that needs to shift the input parameters.
When I do that, the %* value stays the same! Run the following test
script yourself and see the %* always contains the same string, even
after the SHIFT. Is there a work around for this bug? I'm sure
someone must have hit this problem before.

Thanks for any pointers.

================================================
testme.cmd:

@echo off
echo zero="%0", first="%1", second="%2", all="%*"
SHIFT
echo zero="%0", first="%1", second="%2", all="%*"
SHIFT
echo zero="%0", first="%1", second="%2", all="%*"

================================================
run it:
testme one two three
zero="testme", first="one", second="two", all="one two three"
zero="one", first="two", second="three", all="one two three"
zero="two", first="three", second="", all="one two three"
 
I got a response from a Microsoft customer support person. He pointed
me to the article that documents how to use the SHIFT command. It says
explicitly that SHIFT doesn't affect %*. I got my answer but not a
solution to my problem. I don't see why it doesn't. All real command
shells do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top