xref: /aoo42x/main/solenv/bin/guw.pl (revision 7e90fac2)
1cdf0e10cSrcweir:
2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
3cdf0e10cSrcweir    if 0;
4*7e90fac2SAndrew Rist#**************************************************************
5*7e90fac2SAndrew Rist#
6*7e90fac2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
7*7e90fac2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
8*7e90fac2SAndrew Rist#  distributed with this work for additional information
9*7e90fac2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
10*7e90fac2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
11*7e90fac2SAndrew Rist#  "License"); you may not use this file except in compliance
12*7e90fac2SAndrew Rist#  with the License.  You may obtain a copy of the License at
13*7e90fac2SAndrew Rist#
14*7e90fac2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
15*7e90fac2SAndrew Rist#
16*7e90fac2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
17*7e90fac2SAndrew Rist#  software distributed under the License is distributed on an
18*7e90fac2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19*7e90fac2SAndrew Rist#  KIND, either express or implied.  See the License for the
20*7e90fac2SAndrew Rist#  specific language governing permissions and limitations
21*7e90fac2SAndrew Rist#  under the License.
22*7e90fac2SAndrew Rist#
23*7e90fac2SAndrew Rist#**************************************************************
24*7e90fac2SAndrew Rist
25*7e90fac2SAndrew Rist
26cdf0e10cSrcweir# Description: ??
27cdf0e10cSrcweir
28cdf0e10cSrcweir#---------------------------------------------------------------------------
29cdf0e10cSrcweir# external modules
30cdf0e10cSrcweiruse Text::ParseWords;
31cdf0e10cSrcweir
32cdf0e10cSrcweir# global vars
33cdf0e10cSrcweir@params = ();
34cdf0e10cSrcweir
35cdf0e10cSrcweir# set debug mode here:
36cdf0e10cSrcweir#$debug="true";
37cdf0e10cSrcweir#$debug_light="true";
38cdf0e10cSrcweir
39cdf0e10cSrcweir#---------------------------------------------------------------------------
40cdf0e10cSrcweir# Define known parameter exceptions
41cdf0e10cSrcweir%knownpara = ( 'echo', [ '/TEST', 'QQQ', 'CCC', 'uno:' ],
42cdf0e10cSrcweir			   'cl', [ '-clr:', '-Z' ],
43cdf0e10cSrcweir			   'csc', [ '-target:' ],
44cdf0e10cSrcweir			   'lib', [ 'OUT:', 'EXTRACT:','out:', 'def:', 'machine:' ],
45cdf0e10cSrcweir			   'link', [ 'BASE:', 'DEBUG', 'DLL', 'LIBPATH', 'MACHINE:',
46cdf0e10cSrcweir						 'MAP', 'NODEFAULTLIB', 'OPT', 'PDB', 'RELEASE',
47cdf0e10cSrcweir						 'SUBSYSTEM', 'STACK', 'out:', 'map:', 'ENTRY:',
48cdf0e10cSrcweir						 'implib:', 'delayload:', 'def', 'COMMENT:' ],
49cdf0e10cSrcweir			   'regcomp', [ '-env:', 'vnd.sun.star.expand:' , 'vnd.openoffice.pymodule' ],
50cdf0e10cSrcweir			   'regmerge', [ '/UCR' ],
51cdf0e10cSrcweir			   'rc', [ '-D' ],
52cdf0e10cSrcweir			   'rsc', [ '-DOOO_' ] );
53cdf0e10cSrcweir
54cdf0e10cSrcweir#---------------------------------------------------------------------------
55cdf0e10cSrcweir# procedures
56cdf0e10cSrcweir
57cdf0e10cSrcweir
58cdf0e10cSrcweir#----------------------------------------------------------
59cdf0e10cSrcweir# Function name: myCygpath
60cdf0e10cSrcweir# Description:   Transform POSIX path to DOS path
61cdf0e10cSrcweir# Arguments:     1. Variable (string) with one token
62cdf0e10cSrcweir#                2. optional - if set remove spaces and shorten to 8.3
63cdf0e10cSrcweir#                   representation.
64cdf0e10cSrcweir# Return value:  Reformatted String
65cdf0e10cSrcweir#----------------------------------------------------------
66cdf0e10cSrcweirsub myCygpath {
67cdf0e10cSrcweir    my $posixpath = shift;
68cdf0e10cSrcweir    my $shortenpath = shift || '';
69cdf0e10cSrcweir
70cdf0e10cSrcweir    my $dospath;
71cdf0e10cSrcweir
72cdf0e10cSrcweir    if ( $posixpath =~ / / and $shortenpath ) {
73cdf0e10cSrcweir        chomp( $dospath = qx{cygpath -d "$posixpath"} );
74cdf0e10cSrcweir        # "cygpath -d" returns "" if the file doesn't exist.
75cdf0e10cSrcweir        if ($dospath eq "") {
76cdf0e10cSrcweir            $dospath = ".";
77cdf0e10cSrcweir            print(STDERR "Error: guw.pl: Path: $posixpath:\nhas a problem! Probably nonexistent filename with space.\n");
78cdf0e10cSrcweir            if ( (defined $debug_light) or (defined $debug) ) {
79cdf0e10cSrcweir                die "exiting ...\n";
80cdf0e10cSrcweir            }
81cdf0e10cSrcweir        }
82cdf0e10cSrcweir    } else {
83cdf0e10cSrcweir        if ( $posixpath =~ /^\// ) {
84cdf0e10cSrcweir            chomp( $dospath = qx{cygpath -w "$posixpath"} );
85cdf0e10cSrcweir        } else {
86cdf0e10cSrcweir            $dospath = $posixpath;
87cdf0e10cSrcweir            $dospath =~ s/\//\\/g;
88cdf0e10cSrcweir        }
89cdf0e10cSrcweir    }
90cdf0e10cSrcweir    return $dospath;
91cdf0e10cSrcweir}
92cdf0e10cSrcweir
93cdf0e10cSrcweir#----------------------------------------------------------
94cdf0e10cSrcweir# Function name: WinFormat
95cdf0e10cSrcweir# Description:   Format variables to Windows Format.
96cdf0e10cSrcweir# Arguments:     1. Variable (string) with one token
97cdf0e10cSrcweir# Return value:  Reformatted String
98cdf0e10cSrcweir#----------------------------------------------------------
99cdf0e10cSrcweirsub WinFormat {
100cdf0e10cSrcweir  my $variable = shift @_;
101cdf0e10cSrcweir  my( $d1, $d1_prefix, $d2 );
102cdf0e10cSrcweir
103cdf0e10cSrcweir  $variable =~ s/(\$\w+)/$1/eeg ; # expand the variables
104cdf0e10cSrcweir  $variable =~ s/(\$\w+)/$1/eeg ; # expand the variables twice!
105cdf0e10cSrcweir
106cdf0e10cSrcweir  # Include paths or parameters with filenames
107cdf0e10cSrcweir  if ( $variable =~ /\A(-D[\w\.]*=)[\'\"]?((?:\/?[\w\.\-\+ ~]+)+\/?)[\'\"]?\Z/ ) {
108cdf0e10cSrcweir	  # This regex evaluates -D<something>=<path>, sometimes with quotes or "/" at the end
109cdf0e10cSrcweir	  # option -> $1, filename without quotes -> $2
110cdf0e10cSrcweir	  if ( defined $debug ) { print(STDERR "WinFormat:\ninclude (-D<something>=<path>) path:\n$variable\n"); }
111cdf0e10cSrcweir	  $d1_prefix = $1;
112cdf0e10cSrcweir	  $d1 = $2;
113cdf0e10cSrcweir	  $d2 = myCygpath($2,1);
114cdf0e10cSrcweir	  if ( $d2 ne "" ) {
115cdf0e10cSrcweir             $d2 =~ s/\\/\\\\/g ;
116cdf0e10cSrcweir	  }
117cdf0e10cSrcweir  } elsif ( $variable =~ /\A(-?\w[\w\.]*=)[\'\"]?((?:\/?[\w\.\-\+ ~]+)+\/?)[\'\"]?\Z/ ) {
118cdf0e10cSrcweir	  # This regex evaluates [-]X<something>=<path>, sometimes with quotes or "/" at the end
119cdf0e10cSrcweir	  # option -> $1, filename without quotes -> $2
120cdf0e10cSrcweir	  if ( defined $debug ) { print(STDERR "WinFormat:\ninclude ([-]<something>=<path>) path:\n$variable\n"); }
121cdf0e10cSrcweir	  $d1_prefix = $1;
122cdf0e10cSrcweir	  $d1 = $2;
123cdf0e10cSrcweir	  $d2 = myCygpath($2,1);
124cdf0e10cSrcweir  } elsif ( $variable =~ /\A(--\w[\w\.\-]*=)[\'\"]?((?:\/?[\w\.\-\+ ~]+)+\/?)[\'\"]?\Z/ ) {
125cdf0e10cSrcweir	  # This regex evaluates --<something>=<path>, sometimes with quotes or "/" at the end
126cdf0e10cSrcweir	  # option -> $1, filename without quotes -> $2
127cdf0e10cSrcweir	  if ( defined $debug ) { print(STDERR "WinFormat:\ninclude (--<something>=<path>) path:\n$variable\n"); }
128cdf0e10cSrcweir	  $d1_prefix = $1;
129cdf0e10cSrcweir	  $d1 = $2;
130cdf0e10cSrcweir	  $d2 = myCygpath($2,1);
131cdf0e10cSrcweir  } elsif ( $variable =~ /\A(-\w[\w\.]*:)[\'\"]?((?:\/?[\w\.\-\+ ~]+)+\/?)[\'\"]?\Z/ ) {
132cdf0e10cSrcweir	  # This regex evaluates -X<something>:<path>, sometimes with quotes or "/" at the end
133cdf0e10cSrcweir	  # option -> $1, filename without quotes -> $2
134cdf0e10cSrcweir	  if ( defined $debug ) { print(STDERR "WinFormat:\nFound (-<something>:<path>):\n$variable\n"); }
135cdf0e10cSrcweir	  $d1_prefix = $1;
136cdf0e10cSrcweir	  $d1 = $2;
137cdf0e10cSrcweir	  $d2 = myCygpath($2,1);
138cdf0e10cSrcweir  } elsif ( $variable =~ /\A(-\w+:)(.*)\Z/ ) {
139cdf0e10cSrcweir	  # This regex evaluates -X<something>:<NO-path>, and prevents translating of these.
140cdf0e10cSrcweir	  # option -> $1, rest -> $2
141cdf0e10cSrcweir	  if ( defined $debug ) { print(STDERR "WinFormat:\nFound (-<something>:<no-path>):\n$variable\n"); }
142cdf0e10cSrcweir	  $d1_prefix = $1;
143cdf0e10cSrcweir	  $d1 = $2;
144cdf0e10cSrcweir	  $d2 = myCygpath($2,1);
145cdf0e10cSrcweir  } elsif ( $variable =~ /\A(\w+:)[\'\"]?\/\/\/((?:\/?[\w\.\-\+ ~]+)+\/?)[\'\"]?\Z/ ) {
146cdf0e10cSrcweir      # See iz35982 for the reason for the special treatment of this switch.
147cdf0e10cSrcweir      # This regex evaluates <something>:///<path>, sometimes with quotes or "/" at the end
148cdf0e10cSrcweir      # option -> $1, filename without quotes -> $2
149cdf0e10cSrcweir      if ( defined $debug ) { print(STDERR "WinFormat:\nFound (<something>:///<path>):\n$variable\n"); }
150cdf0e10cSrcweir      $d1_prefix = $1."///";
151cdf0e10cSrcweir      $d1 = $2;
152cdf0e10cSrcweir      $d2 = myCygpath($2,1);
153cdf0e10cSrcweir      $d2 =~ s/\\/\//g ;
154cdf0e10cSrcweir  } elsif ( $variable =~ /\A(-\w)[\'\"]?((?:\/[\w\.\-\+ ~]+)+\/?)[\'\"]?\Z/ ) {
155cdf0e10cSrcweir	  # This regex evaluates -X<path>, sometimes with quotes or "/" at the end
156cdf0e10cSrcweir	  # option -> $1, filename without quotes -> $2
157cdf0e10cSrcweir	  if ( defined $debug ) { print(STDERR "WinFormat:\ninclude (-X<absolute path>) path:\n$variable\n"); }
158cdf0e10cSrcweir	  $d1_prefix = $1;
159cdf0e10cSrcweir	  $d1 = $2;
160cdf0e10cSrcweir	  $d2 = myCygpath($2,1);
161cdf0e10cSrcweir  } elsif ( $variable =~ /\A(-F[ARdemopr])[\'\"]?((?:\/[\w\.\-\+ ~]+)+\/?)[\'\"]?\Z/ ) {
162cdf0e10cSrcweir	  # This regex evaluates -FX<path> (MSVC switches for output naming), sometimes with quotes or "/" at the end
163cdf0e10cSrcweir	  # option -> $1, filename without quotes -> $2
164cdf0e10cSrcweir	  if ( defined $debug ) { print(STDERR "WinFormat:\ncompiler naming (-FX<absolute path>) path:\n$variable\n"); }
165cdf0e10cSrcweir	  $d1_prefix = $1;
166cdf0e10cSrcweir	  $d1 = $2;
167cdf0e10cSrcweir	  $d2 = myCygpath($2,1);
168cdf0e10cSrcweir  } else {
169cdf0e10cSrcweir      $d2 = "";
170cdf0e10cSrcweir  }
171cdf0e10cSrcweir  if ( $d2 ne "" ) {
172cdf0e10cSrcweir      # Found a parameter
173cdf0e10cSrcweir      $d1 =~ s/\+/\\\+/ ;
174cdf0e10cSrcweir      $d1 =~ s/\./\\\./ ;
175cdf0e10cSrcweir      $variable =~ s/$d1/$d2/ ;
176cdf0e10cSrcweir  } else {
177cdf0e10cSrcweir    # Found no parameter, assume a path
178cdf0e10cSrcweir    $variable =~ s/:/;/g;
179cdf0e10cSrcweir    $variable =~ s/([;]|\A)(\w);/$1$2:/g; # get back the drives
180cdf0e10cSrcweir
181cdf0e10cSrcweir    # Search for posix path ;entry; (The regex accepts valid paths with at least one /)
182cdf0e10cSrcweir    # and replace with DOS path, accept quotes.
183cdf0e10cSrcweir    # iz28717 Accept ',' as path seperator.
184cdf0e10cSrcweir    while ( $variable =~ /(?:[;,]|\A)[\'\"]?([\w\.\-\+ ~]*(?:\/[\w\.\-\+ ~]+)+\/?)[\'\"]?(?:[;,]|\Z)/ ) {
185cdf0e10cSrcweir        # Normal paths
186cdf0e10cSrcweir        $d1 = $1;
187cdf0e10cSrcweir        $d2 = myCygpath($d1);
188cdf0e10cSrcweir        if ( defined $debug ) {
189cdf0e10cSrcweir            print(STDERR "WinFormat:\nFull path:\n$variable\nTranslated part:$d2\n");
190cdf0e10cSrcweir        }
191cdf0e10cSrcweir	$d1 =~ s/\+/\\\+/ ;
192cdf0e10cSrcweir        $variable =~ s/$d1/$d2/ ;
193cdf0e10cSrcweir    }
194cdf0e10cSrcweir  }
195cdf0e10cSrcweir
196cdf0e10cSrcweir  # Sanity check for -X<path>
197cdf0e10cSrcweir  if ( $variable =~ /-\w[\'\"]?(?:(?:\/[\w\.\-\+ ~]+)+)/ ) {
198cdf0e10cSrcweir	  print(STDERR "Error: guw.pl: WinFormat: Not converted -X/... type switch in :$variable:.\n");
199cdf0e10cSrcweir	  if ( (defined $debug_light) or (defined $debug) ) { die "\nNot processed -X/...\n"; }
200cdf0e10cSrcweir  }
201cdf0e10cSrcweir  # Sanity check for [-]X<something>(:|=)<path> case
202cdf0e10cSrcweir  if ( $variable =~ /\A-?\w[\w\.]*[=:][\'\"]?(?:\/[\w\.\-\+ ~]+)+/ ) {
203cdf0e10cSrcweir	  print(STDERR "Error: guw.pl: WinFormat: Not converted [-]X<something>(=|:)/<path> type switch in :$variable:.\n");
204cdf0e10cSrcweir	  if ( (defined $debug_light) or (defined $debug) ) { die "\nNot processed [-]X<something>(=|:)/...\n"; }
205cdf0e10cSrcweir  }
206cdf0e10cSrcweir
207cdf0e10cSrcweir  if ( defined $debug ) { print(STDERR "WinFormat:\nresult:$variable\n");};
208cdf0e10cSrcweir  return $variable;
209cdf0e10cSrcweir}
210cdf0e10cSrcweir
211cdf0e10cSrcweir#----------------------------------------------------------
212cdf0e10cSrcweir# Function name: replace_cyg
213cdf0e10cSrcweir# Description:   Process all arguments and change them to Windows Format.
214cdf0e10cSrcweir# Arguments:     Reference to array with arguments
215cdf0e10cSrcweir# Return value:  -
216cdf0e10cSrcweir#----------------------------------------------------------
217cdf0e10cSrcweirsub replace_cyg {
218cdf0e10cSrcweir	my $args = shift;
219cdf0e10cSrcweir	my( @cmd_file, @cmd_temp );
220cdf0e10cSrcweir	my $atchars;
221cdf0e10cSrcweir	foreach my $para ( @$args )
222cdf0e10cSrcweir	  {
223cdf0e10cSrcweir		if ( $para =~ "^@" ) {
224cdf0e10cSrcweir		  # it's a command file
225cdf0e10cSrcweir		  if ( defined $debug ) { print(STDERR "----------------------------\n");};
226cdf0e10cSrcweir		  # Workaround, iz28717, keep number of @'s.
227cdf0e10cSrcweir		  $para =~ s/(^\@+)//;
228cdf0e10cSrcweir		  $atchars = $1;
229cdf0e10cSrcweir		  $filename = $para;
230cdf0e10cSrcweir		  if ( defined $debug ) { print(STDERR "filename = $filename \n");};
231cdf0e10cSrcweir		  # open this command file for reading
232cdf0e10cSrcweir		  open(CMD, "$filename");
233cdf0e10cSrcweir		  while ( <CMD> ) {
234cdf0e10cSrcweir			# Remove DOS lineendings. Bug in Cygwin / Perl?
235cdf0e10cSrcweir			$_ =~ s/\r//g;
236cdf0e10cSrcweir			# Remove lineendings and trailing spaces. ( Needed by &parse_line )
237cdf0e10cSrcweir			$_ =~ s/\n$//g;
238cdf0e10cSrcweir			$_ =~ s/\s+$//g;
239cdf0e10cSrcweir			# Fill all tokens into array
240cdf0e10cSrcweir            @cmd_temp = &parse_line('\s+', 1, $_ );
241cdf0e10cSrcweir			if ( $#cmd_temp > -1 ) {
242cdf0e10cSrcweir				push( @cmd_file, @cmd_temp);
243cdf0e10cSrcweir            }
244cdf0e10cSrcweir		  }
245cdf0e10cSrcweir		  close(CMD);
246cdf0e10cSrcweir		  # reformat all tokens
247cdf0e10cSrcweir		  replace_cyg(\@cmd_file);
248cdf0e10cSrcweir		  if ( defined $debug ) { print(STDERR "Tokens processed:\n");};
249cdf0e10cSrcweir		  foreach $i (@cmd_file) {
250cdf0e10cSrcweir			if ( defined $debug ) { print(STDERR "!".$i."!\n");};
251cdf0e10cSrcweir		  }
252cdf0e10cSrcweir		  # open this filename for writing (truncate) Textmode?
253cdf0e10cSrcweir		  open(CMD, '>', $filename);
254cdf0e10cSrcweir		  # write all tokens back into this file
255cdf0e10cSrcweir		  print(CMD join(' ', @cmd_file));
256cdf0e10cSrcweir		  close(CMD);
257cdf0e10cSrcweir		  # convert '@filename' to dos style
258cdf0e10cSrcweir		  $para = WinFormat( $para );
259cdf0e10cSrcweir		  if ( defined $debug ) { print(STDERR "----------------------------\n");};
260cdf0e10cSrcweir		  if ( (defined $debug_light) or (defined $debug) ) { print(STDERR "\nParameter in File:".join(' ', @cmd_file).":\n");}
261cdf0e10cSrcweir		  $para = $atchars.$para;
262cdf0e10cSrcweir		} else {
263cdf0e10cSrcweir		  # it's just a parameter
264cdf0e10cSrcweir		  if ( defined $debug ) { print(STDERR "\nParameter:---${para}---\n");};
265cdf0e10cSrcweir		  # If $tmp1 is empty then $para is a parameter.
266cdf0e10cSrcweir		  my $is_no_para = 1;
267cdf0e10cSrcweir		  # remove .exe and convert to lower case
268cdf0e10cSrcweir		  $shortcommand = lc $command ;
269cdf0e10cSrcweir		  $shortcommand =~ s/\.exe$//;
270cdf0e10cSrcweir		  $shortcommand =~ /([^\/]+$)/;
271cdf0e10cSrcweir		  $shortcommand = $1;
272cdf0e10cSrcweir		  foreach $i (@{$knownpara{$shortcommand}}) {
273cdf0e10cSrcweir			if( $para =~ /$i/ ) {
274cdf0e10cSrcweir			  $is_no_para = 0;
275cdf0e10cSrcweir			  if ( defined $debug ) { print(STDERR "Is parameter exception for ${shortcommand}: ${para}:\n" );};
276cdf0e10cSrcweir			  last;
277cdf0e10cSrcweir			}
278cdf0e10cSrcweir		  }
279cdf0e10cSrcweir		  if( $is_no_para ) {
280cdf0e10cSrcweir			$para = WinFormat($para);
281cdf0e10cSrcweir		  }
282cdf0e10cSrcweir		  if ( defined $debug ) { print(STDERR "Converted line:${para}:\n" );};
283cdf0e10cSrcweir		} # else
284cdf0e10cSrcweir	  } # foreach loop
285cdf0e10cSrcweir}
286cdf0e10cSrcweir
287cdf0e10cSrcweir#----------------------------------------------------------
288cdf0e10cSrcweir# Function name: replace_cyg_env
289cdf0e10cSrcweir# Description:   Process selected environment variables and change
290cdf0e10cSrcweir#                them to Windows Format.
291cdf0e10cSrcweir# Arguments:     -
292cdf0e10cSrcweir# Return value:  -
293cdf0e10cSrcweir#----------------------------------------------------------
294cdf0e10cSrcweirsub replace_cyg_env {
295cdf0e10cSrcweir    @affected_vars = (
296cdf0e10cSrcweir        'SOLAR_VERSION',
297cdf0e10cSrcweir        'SOLARVERSION',
298cdf0e10cSrcweir        'SOLARVER',
299cdf0e10cSrcweir        'SRC_ROOT',
300cdf0e10cSrcweir        'LOCALINI',
301cdf0e10cSrcweir        'GLOBALINI',
302cdf0e10cSrcweir        'SOLARENV',
303cdf0e10cSrcweir        'STAR_INSTPATH',
304cdf0e10cSrcweir        'STAR_SOLARPATH',
305cdf0e10cSrcweir        'STAR_PACKMISC',
306cdf0e10cSrcweir        'STAR_SOLARENVPATH',
307cdf0e10cSrcweir        'STAR_INITROOT',
308cdf0e10cSrcweir        'STAR_STANDLST',
309cdf0e10cSrcweir        'CLASSPATH',
310cdf0e10cSrcweir        'JAVA_HOME'
311cdf0e10cSrcweir    );
312cdf0e10cSrcweir    foreach my $one_var ( @affected_vars )
313cdf0e10cSrcweir    {
314cdf0e10cSrcweir        my $this_var = $ENV{ $one_var };
315cdf0e10cSrcweir        if ( defined $this_var )
316cdf0e10cSrcweir        {
317cdf0e10cSrcweir            if ( defined $debug ) { print(STDERR "ENV $one_var before: ".$ENV{ $one_var}."\n" );};
318cdf0e10cSrcweir            $ENV{ $one_var } = WinFormat( $this_var );
319cdf0e10cSrcweir            if ( defined $debug ) { print(STDERR "ENV $one_var after : ".$ENV{ $one_var}."\n" );};
320cdf0e10cSrcweir        }
321cdf0e10cSrcweir    }
322cdf0e10cSrcweir
323cdf0e10cSrcweir}
324cdf0e10cSrcweir#---------------------------------------------------------------------------
325cdf0e10cSrcweir# main
326cdf0e10cSrcweir@params = @ARGV;
327cdf0e10cSrcweir
328cdf0e10cSrcweir$command = shift(@params);
329cdf0e10cSrcweirwhile ( $command =~ /^-/ )
330cdf0e10cSrcweir{
331cdf0e10cSrcweir    if ( $command eq "-env" )
332cdf0e10cSrcweir    {
333cdf0e10cSrcweir        replace_cyg_env;
334cdf0e10cSrcweir    }
335cdf0e10cSrcweir
336cdf0e10cSrcweir    $command = shift(@params);
337cdf0e10cSrcweir}
338cdf0e10cSrcweirif ( (defined $debug_light) or (defined $debug) ) { print( STDERR "Command: $command\n" ); }
339cdf0e10cSrcweir
340cdf0e10cSrcweirreplace_cyg(\@params);
341cdf0e10cSrcweirif ( (defined $debug_light) or (defined $debug) ) { print(STDERR "\n---------------------\nExecute: $command @params\n----------------\n");};
342cdf0e10cSrcweirexec( "$command", @params) or die( "\nError: guw.pl: executing $command failed!\n" );
343cdf0e10cSrcweir
344