1

I'm trying to create a GNU like configure script for Windows in a batch file. It seems to work ok so far except depending on the order options get ignored and in particular with the '--with-smtube' option it sometimes gets the path but again depending on the order causes it to result in:

test.cmd --enable-portable --with-smtube=C:\svn\smtube

configure: error: unrecognized option: `C:\svn\smtube'
Try `--with-smtube --help' for more information

(supposed to also say Try `test.cmd --help)

I copied the structure from another script I found but not having success. The order of arguments shouldn't matter and arguments can be omitted (all or some). Can someone steer me in the right direction?

The script is for a Qt program, it uses command prompt as the shell and not msys or cygwin or anything like that.

This is what I have so far: http://redxii.users.sourceforge.net/test.cmd

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
  • Figured it out, I was excessively using 'shift'. Only needed it for the smtube directory and at the end of the loop after the last closing parenthesis on the if/else statements. Except %0 still returns the last parameter instead of the batch file name. – user1814942 Nov 10 '12 at 19:13
  • You should have a look at my answer to [Windows Bat file optional argument parsing](http://stackoverflow.com/a/8162578/1012053). Read the original question and then see if my answer applies to your situation. I think you might like it :-) – dbenham Nov 10 '12 at 21:01
  • As far as preserving %0 to be the filename of the script I just created my own variable copied from %0 before the loop. – user1814942 Nov 12 '12 at 07:09

0 Answers0