mirror of
https://git.proxmox.com/git/pve-common
synced 2025-04-29 00:03:47 +00:00
use Text::ParseWords for split_args
This commit is contained in:
parent
f912566320
commit
e38bcd3597
@ -13,6 +13,7 @@ use base 'Exporter';
|
|||||||
use URI::Escape;
|
use URI::Escape;
|
||||||
use Encode;
|
use Encode;
|
||||||
use Digest::SHA1;
|
use Digest::SHA1;
|
||||||
|
use Text::ParseWords;
|
||||||
|
|
||||||
our @EXPORT_OK = qw(
|
our @EXPORT_OK = qw(
|
||||||
lock_file
|
lock_file
|
||||||
@ -709,30 +710,11 @@ sub shellquote {
|
|||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
# a clumsy way to split an shell argument string into an array,
|
# split an shell argument string into an array,
|
||||||
# we simply pass it to the cli (exec call)
|
|
||||||
# fixme: use Text::ParseWords::shellwords() ?
|
|
||||||
sub split_args {
|
sub split_args {
|
||||||
my ($str) = @_;
|
my ($str) = @_;
|
||||||
|
|
||||||
my $args = [];
|
return $str ? [ Text::ParseWords::shellwords($str) ] : [];
|
||||||
|
|
||||||
return $args if !$str;
|
|
||||||
|
|
||||||
my $cmd = 'perl -e \'foreach my $a (@ARGV) { print "$a\n"; } \' -- ' . $str;
|
|
||||||
|
|
||||||
eval {
|
|
||||||
run_command($cmd, outfunc => sub {
|
|
||||||
my $data = shift;
|
|
||||||
push @$args, $data;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
my $err = $@;
|
|
||||||
|
|
||||||
die "unable to parse args: $str\n" if $err;
|
|
||||||
|
|
||||||
return $args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user