#!perl
+use Config;
use Cwd;
use strict;
["\ta b c ", " "],
["", "\ta b c ", "abc"],
[" ", "\ta b c ", "abc"],
+ ['" "', 'a" "b" "c', "abc"],
);
print "1.." . (@commands * @av * 2) . "\n";
my @cmds = defined($cmds) ? (ref($cmds) ? @$cmds : $cmds) : ();
my @args = defined($args) ? (ref($args) ? @$args : $args) : ();
print "######## [@cmds]\n";
- print "<", join('><', $cmds[$#cmds], @args), ">\n";
+ print "<", join('><',
+ $cmds[$#cmds],
+ map { my $x = $_; $x =~ s/"//g; $x } @args),
+ ">\n";
if (system(@cmds,@args) != 0) {
print "Failed, status($?)\n";
-# print "Running again in debug mode\n";
-# $^D = 1; # -Dp
-# system(@cmds,@args);
+ if ($Config{ccflags} =~ /\bDDEBUGGING\b/) {
+ print "Running again in debug mode\n";
+ $^D = 1; # -Dp
+ system(@cmds,@args);
+ }
}
$^D = 0;
- my $cmdstr = join " ", map { /\s|^$/ ? qq["$_"] : $_ } @cmds, @args;
+ my $cmdstr = join " ", map { /\s|^$/ && !/\"/
+ ? qq["$_"] : $_ } @cmds, @args;
print "######## '$cmdstr'\n";
if (system($cmdstr) != 0) {
print "Failed, status($?)\n";
-# print "Running again in debug mode\n";
-# $^D = 1; # -Dp
-# system($cmdstr);
+ if ($Config{ccflags} =~ /\bDDEBUGGING\b/) {
+ print "Running again in debug mode\n";
+ $^D = 1; # -Dp
+ system($cmdstr);
+ }
}
$^D = 0;
}
if (!curlen) {
do_quote = 1;
}
+ else if (quote_next) {
+ /* see if it really is multiple arguments pretending to
+ * be one and force a set of quotes around it */
+ if (*find_next_space(arg))
+ do_quote = 1;
+ }
else if (!(arg[0] == '"' && curlen > 1 && arg[curlen-1] == '"')) {
STRLEN i = 0;
while (i < curlen) {
if (isSPACE(arg[i])) {
do_quote = 1;
+ }
+ else if (arg[i] == '"') {
+ do_quote = 0;
break;
}
i++;
}
}
- else if (quote_next) {
- /* ok, we know the argument already has quotes; see if it
- * really is multiple arguments pretending to be one and
- * force a set of quotes around it */
- if (*find_next_space(arg))
- do_quote = 1;
- }
}
if (do_quote)
extra_quotes = TRUE;
}
else {
- /* single argument, force quoting if unquoted */
+ /* single argument, force quoting if it has spaces */
quote_next = TRUE;
}
}