]> git.proxmox.com Git - pve-client.git/blobdiff - PVE/Tools.pm
fixup for previous commit: really set blocking mode
[pve-client.git] / PVE / Tools.pm
index dddf1c08416a4bf3680de30abaea411e29b9dbbb..cd55932c8a9cffaa5e96b5bfff0744a89ddeea43 100644 (file)
@@ -6,6 +6,7 @@ use POSIX qw(EINTR EEXIST EOPNOTSUPP);
 use base 'Exporter';
 
 use IO::File;
+use Text::ParseWords;
 
 our @EXPORT_OK = qw(
 $IPV6RE
@@ -13,6 +14,7 @@ $IPV4RE
 split_list
 file_set_contents
 file_get_contents
+extract_param
 );
 
 my $IPV4OCTET = "(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])";
@@ -126,4 +128,20 @@ sub split_list {
     return @data;
 }
 
+# split an shell argument string into an array,
+sub split_args {
+    my ($str) = @_;
+
+    return $str ? [ Text::ParseWords::shellwords($str) ] : [];
+}
+
+sub extract_param {
+    my ($param, $key) = @_;
+
+    my $res = $param->{$key};
+    delete $param->{$key};
+
+    return $res;
+}
+
 1;