mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 14:35:25 +00:00
test-wrap-argv: use map and join instead of a for cycle
We have a list of parameters in @args, that need to be rewrapped and separated by a space and escaped newline: " \\\n", with the exception of the last one, which only needs a newline. Instead of a for cycle, rewrap the individual arguments using map, and interleave them with escaped newlines by using join.
This commit is contained in:
parent
2f071f1fca
commit
c8da1cbf13
@ -100,18 +100,10 @@ sub rewrap_line {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Print env + command first
|
|
||||||
print join(" \\\n", @env, $cmd), " \\\n";
|
|
||||||
# We might have to split line argument values...
|
# We might have to split line argument values...
|
||||||
for (my $i = 0; $i <= $#args; $i++) {
|
@args = map { &rewrap_arg($_) } @args;
|
||||||
print &rewrap_arg($args[$i]);
|
# Print env + command first
|
||||||
|
print join(" \\\n", @env, $cmd, @args), "\n";
|
||||||
if ($i != $#args) {
|
|
||||||
print " \\\n";
|
|
||||||
} else {
|
|
||||||
print "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub rewrap_arg {
|
sub rewrap_arg {
|
||||||
|
Loading…
Reference in New Issue
Block a user