Fired up ye olde VM, and found the solution. You see, you can write a batch script that does the parsing for you... it looks like this:
@ECHO OFF SetLocal EnableDelayedExpansion set ARGS= :parse_args if not %1.==. ( set ARG=%1 set ARGS=!ARGS! ^"!ARG:"=\"!^" shift goto :parse_args ) call perl getargs.pl %ARGS%
I rewrote the perscript to fit the output of your C code, but it is basically the same:
unshift(@ARGV,$0); for my $n (0..$#ARGV) { print "$n:$ARGV[$n]:\n" }
The resulting output is then:
C:\>parseargs.bat "abc "" def" bob 0:getargs.pl: 1:"abc "" def": 2:bob:
Which is not exactly the same what you wanted, but it is actually exactly what you typed in as arguments. Now, it is time to s/""/"/g and you are ready to go. What I mean is:
unshift(@ARGV,$0); @ARGV = map {s/^"(.*)"$/$1/ ? s/""/"/g && $_ : $_ } @ARGV; for my $n (0..$#ARGV) { print "$n:$ARGV[$n]:\n" }
Dont ask why I used map... I am not sober at the moment...
0:getargs.pl: 1:abc " def: 2:bob:
note to self: do not forget bob
In reply to Re: Parsing Windows CommandLine from Perl
by FreeBeerReekingMonk
in thread Parsing Windows CommandLine from Perl
by eyepopslikeamosquito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |