]> git.proxmox.com Git - pve-common.git/commitdiff
new helper cmd2string
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 1 Dec 2011 06:37:22 +0000 (07:37 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 2 Dec 2011 05:15:36 +0000 (06:15 +0100)
data/PVE/Tools.pm

index b42a5bb5f603b4ff5b3d13a9503aabb9067f2a64..1a8d33c3b8102150667bf886071befd57be19c30 100644 (file)
@@ -170,7 +170,7 @@ sub run_command {
 
     $cmd = [ $cmd ] if !ref($cmd);
 
-    my $cmdstr = join (' ', @$cmd);
+    my $cmdstr = cmd2string($cmd);
 
     my $errmsg;
     my $laststderr;
@@ -695,6 +695,19 @@ sub shellquote {
     return String::ShellQuote::shell_quote($str);
 }
 
+sub cmd2string {
+    my ($cmd) = @_;
+
+    die "no arguments" if !$cmd;
+
+    return $cmd if !ref($cmd);
+
+    my @qa = ();
+    foreach my $arg (@$cmd) { push @qa, shellquote($arg); }
+
+    return join (' ', @qa);
+}
+
 # split an shell argument string into an array,
 sub split_args {
     my ($str) = @_;