|23 Feb 2012||#1|
| || |
Command-line wildcard arguments - not expanding
Recently, I tried testing a small utility I wrote (in C). I found it wasn't behaving as expected when invoking the program from the command line. I have attempted to Google for more information regarding Windows 7 command-line wildcards, but haven't found anything specifically helpful to my case.
"Quick Edit mode" and "Insert mode" are enabled on my CMD shortcut.
The problem is that, when invoking my own programs, using wildcards to match multiple files results in the literal wildcard being passed as an argument instead of the expanded list. So, I wrote a small test program that simply echoes back the arguments passed, and here's what it looks like:
C:\Users\curtis\dev\xmv>cl /O2 /Wall args.c && rm *.obj Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. args.c Microsoft (R) Incremental Linker Version 10.00.40219.01 Copyright (C) Microsoft Corporation. All rights reserved. /out:args.exe args.obj C:\Users\curtis\dev\xmv>dir Volume in drive C is OS Volume Serial Number is 3624-94BA Directory of C:\Users\curtis\dev\xmv 02/23/2012 12:08 AM <DIR> . 02/23/2012 12:08 AM <DIR> .. 02/23/2012 12:02 AM 171 args.c 02/23/2012 12:08 AM 39,936 args.exe 02/22/2012 10:12 PM <DIR> include 03/17/2007 04:16 AM 7,378 pcre.lib 03/17/2007 04:16 AM 3,250 pcreposix.lib 02/22/2012 08:42 PM 533 rename.c 02/22/2012 09:47 PM 2,938 replace.c 02/22/2012 09:47 PM 2,353 xmv.c 02/22/2012 09:47 PM 50,688 xmv.exe 8 File(s) 107,247 bytes 3 Dir(s) 422,124,756,992 bytes free C:\Users\curtis\dev\xmv>args *.c *.c C:\Users\curtis\dev\xmv>
Since batch scripts seem to echo out wildcard expansions correctly, I tried:
C:\Users\curtis\dev\xmv>type test.bat @echo off args %* C:\Users\curtis\dev\xmv>test *.c *.c C:\Users\curtis\dev\xmv>
If I run the same "args" program in a Cygwin terminal, the wildcard operates as expected, even when invoking my own programs.
|My System Specs|
|Similar help and support threads for2: Command-line wildcard arguments - not expanding|
|UAC bug with runas from command line?||General Discussion|
|How can I set this via command-line or registry?||Customization|
|Gpedit via command line||Performance & Maintenance|
|libraries and the command line||Performance & Maintenance|
|How to run a command line utility?||General Discussion|
|Command Line||General Discussion|
|Can you boot from the command line?||Chillout Room|
|Our Sites ||Site Links ||About Us ||Find Us |
© Designer Media Ltd
All times are GMT -5. The time now is 12:37 AM.