2 eval 'exec perl -wS $0 ${1+"$@"}'
5 # This file is part of the LibreOffice project.
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # This file incorporates work covered by the following license notice:
13 # Licensed to the Apache Software Foundation (ASF) under one or more
14 # contributor license agreements. See the NOTICE file distributed
15 # with this work for additional information regarding copyright
16 # ownership. The ASF licenses this file to you under the Apache
17 # License, Version 2.0 (the "License"); you may not use this file
18 # except in compliance with the License. You may obtain a copy of
19 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 # Description: Wrapper script to change '/' to '\' in command-line
24 #---------------------------------------------------------------------------
31 #---------------------------------------------------------------------------
35 #----------------------------------------------------------
36 # Function name: WinFormat
37 # Description: Format variables to Windows Format.
38 # Arguments: 1. Variable (string) with one token
39 # Return value: Reformatted String
40 #----------------------------------------------------------
42 my $variable = shift @_;
44 $variable =~ s!(.)/!$1\\!g; # Replace all but the leading slashes with backslashes
46 if ( defined $debug ) {
47 print(STDERR
"WinFormat:\nresult:$variable\n");
53 #----------------------------------------------------------
54 # Function name: replace_cyg
55 # Description: Process all arguments and change them to Windows Format.
56 # Arguments: Reference to array with arguments
58 #----------------------------------------------------------
61 my( @cmd_file, @cmd_temp );
63 foreach my $para ( @
$args ) {
64 if ( $para =~ "^@" ) {
66 if ( defined $debug ) {
67 print(STDERR
"----------------------------\n");
70 # Workaround, iz28717, keep number of @'s.
74 if ( defined $debug ) {
75 print(STDERR
"filename = $filename \n");
78 # open this command file for reading
79 open(CMD
, "$filename");
81 # Remove DOS lineendings. Bug in Cygwin / Perl?
83 # Remove lineendings and trailing spaces. ( Needed by &parse_line )
86 # Fill all tokens into array
87 @cmd_temp = &parse_line
('\s+', 1, $_ );
88 if ( $#cmd_temp > -1 ) {
89 push( @cmd_file, @cmd_temp);
94 replace_cyg
(\
@cmd_file);
95 if ( defined $debug ) {
96 print(STDERR
"Tokens processed:\n");
99 foreach $i (@cmd_file) {
100 if ( defined $debug ) {
101 print(STDERR
"!".$i."!\n");
105 # open this filename for writing (truncate) Textmode?
106 open(CMD
, '>', $filename);
107 # write all tokens back into this file
108 print(CMD
join(' ', @cmd_file));
110 # convert '@filename' to dos style
111 $para = WinFormat
( $para );
112 if ( defined $debug ) {
113 print(STDERR
"----------------------------\n");
116 if ( (defined $debug_light) or (defined $debug) ) {
117 print(STDERR
"\nParameter in File:".join(' ', @cmd_file).":\n");
119 $para = $atchars.$para;
121 # it's just a parameter
122 if ( defined $debug ) {
123 print(STDERR
"\nParameter:---${para}---\n");
126 # If $tmp1 is empty then $para is a parameter.
128 # remove .exe and convert to lower case
129 $shortcommand = lc $command ;
130 $shortcommand =~ s/\.exe$//;
131 $shortcommand =~ /([^\/]+$)/;
134 $para = WinFormat
($para);
136 if ( defined $debug ) {
137 print(STDERR
"Converted line:${para}:\n" );
144 #---------------------------------------------------------------------------
148 $command = shift(@params);
150 while ( $command =~ /^-/ )
152 if ( $command eq "-dbg" ) {
155 elsif ( $command eq "-ldbg" ) {
159 $command = shift(@params);
162 if ( (defined $debug_light) or (defined $debug) ) { print( STDERR
"Command: $command\n" ); }
164 replace_cyg
(\
@params);
165 if ( (defined $debug_light) or (defined $debug) ) { print(STDERR
"\n---------------------\nExecute: $command @params\n----------------\n");};
166 exec( "$command", @params) or die( "\nError: slfl.pl: executing $command failed!\n" );