projects
/
pve-common.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a0f855e
)
new helper cmd2string
author
Dietmar Maurer
<dietmar@proxmox.com>
Thu, 1 Dec 2011 06:37:22 +0000
(07:37 +0100)
committer
Dietmar Maurer
<dietmar@proxmox.com>
Fri, 2 Dec 2011 05:15:36 +0000
(06:15 +0100)
data/PVE/Tools.pm
patch
|
blob
|
blame
|
history
diff --git
a/data/PVE/Tools.pm
b/data/PVE/Tools.pm
index b42a5bb5f603b4ff5b3d13a9503aabb9067f2a64..1a8d33c3b8102150667bf886071befd57be19c30 100644
(file)
--- a/
data/PVE/Tools.pm
+++ b/
data/PVE/Tools.pm
@@
-170,7
+170,7
@@
sub run_command {
$cmd = [ $cmd ] if !ref($cmd);
$cmd = [ $cmd ] if !ref($cmd);
- my $cmdstr =
join (' ', @
$cmd);
+ my $cmdstr =
cmd2string(
$cmd);
my $errmsg;
my $laststderr;
my $errmsg;
my $laststderr;
@@
-695,6
+695,19
@@
sub shellquote {
return String::ShellQuote::shell_quote($str);
}
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) = @_;
# split an shell argument string into an array,
sub split_args {
my ($str) = @_;