in reply to Re: Quote marks lost in system() calls
in thread Quote marks lost in system() calls

I tried the following on NT 4.0 with ActiveState 5.005_03.
if ( @ARGV ) {
    foreach my $i ( 0 .. $#ARGV ) {
        print "ARVG[$i]: ", $ARGV[$i], "\n";
    }
    exit(0);
}
system("perl $0 foo bar");
system('perl ' . $0 . ' "foo bar"');
system("perl $0 foo \"bar baz\"");
system("perl $0 foo \"\"bar baz\"\"");
system("perl", $0, "foo", '"bar baz"');
which yielded
ARVG[0]: foo
ARVG[1]: bar
ARVG[0]: foo bar
ARVG[0]: foo
ARVG[1]: bar baz
ARVG[0]: foo
ARVG[1]: bar
ARVG[2]: baz
ARVG[0]: foo
ARVG[1]: bar baz
Unless I missed something, this suggests that you may be SOL on getting the doublequotes passed through on NT.
  • Comment on Re: Re: Quote marks lost in system() calls

Replies are listed 'Best First'.
Re: Re: Re: Quote marks lost in system() calls
by runrig (Abbot) on Dec 21, 2000 at 05:51 UTC
    This seems to behave as you desire, though I'm still not sure if its what Three-G wants (from his description, I thought its what I previously posted):
    if ( @ARGV ) { foreach my $i ( 0 .. $#ARGV ) { print "ARVG[$i]: ", $ARGV[$i], "\n"; } exit(0); } system("perl", $0, 'foo', '"\"bar baz\""'); # or this: system("perl", $0, 'foo', qq("\\"bar baz\\"")); ARVG[0]: foo ARVG[1]: "bar baz"
      Ha! Good catch. ++ for runrig.