return $mac;
}
+sub shellquote {
+ my $str = shift;
+
+ return "''" if !defined ($str) || ($str eq '');
+
+ die "unable to quote string containing null (\\000) bytes"
+ if $str =~ m/\x00/;
+
+ # from String::ShellQuote
+ if ($str =~ m|[^\w!%+,\-./:@^]|) {
+
+ # ' -> '\''
+ $str =~ s/'/'\\''/g;
+
+ $str = "'$str'";
+ $str =~ s/^''//;
+ $str =~ s/''$//;
+ }
+
+ return $str;
+}
+
+# a clumsy way to 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 {
+ my ($str) = @_;
+
+ my $args = [];
+
+ 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;