[PATCH 4/8] test-wrap-argv: use map and join instead of a for cycle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 tests/test-wrap-argv.pl | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/tests/test-wrap-argv.pl b/tests/test-wrap-argv.pl
index 693bed5..4e942cd 100755
--- a/tests/test-wrap-argv.pl
+++ b/tests/test-wrap-argv.pl
@@ -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...
-    for (my $i = 0; $i <= $#args; $i++) {
-        print &rewrap_arg($args[$i]);
-
-        if ($i != $#args) {
-            print " \\\n";
-        } else {
-            print "\n";
-        }
-    }
+    @args = map { &rewrap_arg($_) } @args;
+    # Print env + command first
+    print join(" \\\n", @env, $cmd, @args), "\n";
 }
 
 sub rewrap_arg {
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]