Fix overly-complex 'map' (PBP)

This commit is contained in:
Dan Church 2023-07-20 15:00:46 -05:00
parent 7d389377a1
commit e0c91b4647
Signed by: h3xx
GPG Key ID: EA2BF379CD2CDBD0
1 changed files with 5 additions and 6 deletions

View File

@ -39,12 +39,11 @@ sub hr_size {
sub shell_quote {
# shell-escape argument for inclusion in non-interpolated single quotes
my @words = @_;
my @transformed = map {
(my $out = $_)
=~ s/'/'\\''/g;
"'$out'";
} @words;
return wantarray ? @transformed : $transformed[0];
foreach my $word (@words) {
$word =~ s/'/'\\''/g;
$word = "'$word'";
}
return wantarray ? @words : $words[0];
}
1;