mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-15 08:02:01 +00:00
new helper cmd2string
This commit is contained in:
parent
a0f855e64c
commit
65e1d3fc9c
@ -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) = @_;
|
||||
|
Loading…
Reference in New Issue
Block a user