[Libreoffice-commits] .: solenv/bin

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 23 02:21:54 PST 2013


 solenv/bin/exectest.pl |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 409de33c5739db45b896935c79eba40b68e106ec
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 23 11:18:55 2013 +0100

    In exectest.pl support commands prefixed by shell-style variable assignments
    
    ...and properly encode the command passed to Perl's open "|...", which in turn
    apparently passes the command to the shell.
    
    Change-Id: I19ab8f677dced6c1421fd9b4910d8a84743c1506

diff --git a/solenv/bin/exectest.pl b/solenv/bin/exectest.pl
index d504d62..06c9072 100644
--- a/solenv/bin/exectest.pl
+++ b/solenv/bin/exectest.pl
@@ -16,6 +16,13 @@
 #   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 #
 
+sub encode($)
+{
+    my ($arg) = @_;
+    $arg =~ s/'/'\\''/g;
+    return $arg
+}
+
 $#ARGV >= 1
     or die "Usage: $0 <input file>|-SUCCESS|-FAILURE <command> <arguments...>";
 if ($ARGV[0] eq "-SUCCESS")
@@ -78,7 +85,22 @@ while (1) {
         {
             undef $title;
         }
-        open PIPE, "| @ARGV" or die "cannot start process: $!";
+        my $prog = '';
+        my $assigns = 1;
+        for ($i = 0; $i != scalar(@ARGV); ++$i)
+        {
+            $prog .= ' ' unless $i == 0;
+            if ($assigns && $ARGV[$i] =~ /^([A-Za-z_][A-Za-z0-9_]+)=(.*)$/)
+            {
+                $prog .= $1 . "='" . encode($2) . "'";
+            }
+            else
+            {
+                $prog .= "'" . encode($ARGV[$i]) . "'";
+                $assigns = 0;
+            }
+        }
+        open PIPE, "| $prog" or die "cannot start process: $!";
         $open = 1;
     }
     elsif ($open && $input)


More information about the Libreoffice-commits mailing list