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 { sub shell_quote {
# shell-escape argument for inclusion in non-interpolated single quotes # shell-escape argument for inclusion in non-interpolated single quotes
my @words = @_; my @words = @_;
my @transformed = map { foreach my $word (@words) {
(my $out = $_) $word =~ s/'/'\\''/g;
=~ s/'/'\\''/g; $word = "'$word'";
"'$out'"; }
} @words; return wantarray ? @words : $words[0];
return wantarray ? @transformed : $transformed[0];
} }
1; 1;