projects/aports·blob master · refs

39 lines · 890 B

1Avoid having to add perl-win32-shellquote aport
2which won't be used anyway as this isn't Windows
3
4--- a/lib/Command/Runner/Quote.pm
5+++ b/lib/Command/Runner/Quote.pm
6@@ -2,15 +2,31 @@
7 use strict;
8 use warnings;
9
10-use Win32::ShellQuote ();
11 use String::ShellQuote ();
12
13 use Exporter 'import';
14 our @EXPORT_OK = qw(quote quote_win32 quote_unix);
15
16+sub win32_quote_literal {
17+ my ($text, $force) = @_;
18+
19+ # basic argument quoting. uses backslashes and quotes to escape
20+ # everything.
21+ if (!$force && $text ne '' && $text !~ /[ \t\n\x0b"]/) {
22+ # no quoting needed
23+ }
24+ else {
25+ $text =~ s{(\\*)(?="|\z)}{$1$1}g;
26+ $text =~ s{"}{\\"}g;
27+ $text = qq{"$text"};
28+ }
29+
30+ return $text;
31+}
32+
33 sub quote_win32 {
34 my $str = shift;
35- Win32::ShellQuote::quote_literal($str, 1);
36+ win32_quote_literal($str, 1);
37 }
38
39 sub quote_unix {