antRun.pl revision 0
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#!/usr/bin/perl
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# Copyright 2001,2003-2004 The Apache Software Foundation
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#
9541e63de5a0e8de81d8f741de795a458ce0cbdeLaszlo Hordos# Licensed under the Apache License, Version 2.0 (the "License");
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# you may not use this file except in compliance with the License.
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# You may obtain a copy of the License at
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# http://www.apache.org/licenses/LICENSE-2.0
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# Unless required by applicable law or agreed to in writing, software
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# distributed under the License is distributed on an "AS IS" BASIS,
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# See the License for the specific language governing permissions and
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# limitations under the License.
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#######################################################################
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# antRun.pl
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# wrapper script for invoking commands on a platform with Perl installed
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# this is akin to antRun.bat, and antRun the SH script
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos#
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# created: 2001-10-18
9414015dda290f99570edc01b6dbe98f0f4c49c7Laszlo Hordos# author: Jeff Tulley jtulley@novell.com
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#######################################################################
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#be fussy about variables
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryanuse strict;
95a1999c80b3861230dabc65b91d0b802a3b62f0Paul Bryan
89770737c72ebabf6e5a7610f398eeffa653b05fBrendan Mmiller#turn warnings on during dev; generates a few spurious uninitialised var access warnings
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#use warnings;
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan#and set $debug to 1 to turn on trace info (currently unused)
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryanmy $debug=1;
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos#######################################################################
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos# change drive and directory to "%1"
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordosmy $ANT_RUN_CMD = @ARGV[0];
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos# assign current run command to "%2"
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordoschdir (@ARGV[0]) || die "Can't cd to $ARGV[0]: $!\n";
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordosif ($^O eq "NetWare") {
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos # There is a bug in Perl 5 on NetWare, where chdir does not
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos # do anything. On NetWare, the following path-prefixed form should
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos # always work. (afaict)
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos $ANT_RUN_CMD .= "/".@ARGV[1];
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos}
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordoselse {
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos $ANT_RUN_CMD = @ARGV[1];
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos}
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos
e9aaa1f1adc6f718befc047fe7177bdf52198c3aLaszlo Hordos# dispose of the first two arguments, leaving only the command's args.
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryanshift;
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryanshift;
1965c5d21403c3d66eb1efa29c670378311b1077Paul Bryan
29b501990ace032d7b959ac1afd1ec75533e8baePaul Bryan# run the command
bf3adaa7953ef4d249670fa82f2a0f7f17ee4b7bLaszlo Hordosmy $returnValue = system $ANT_RUN_CMD, @ARGV;
0fdda69ce3627d501e4bb3103765f676bb1ab061Laszlo Hordosif ($returnValue eq 0) {
43689602ee8a67deb29ea8412c48410dcaa6b30aLaszlo Hordos exit 0;
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordos}
376d1bf8f8ca562eecccbf0a0d34aa7c7352e152Laszlo Hordoselse {
bf3adaa7953ef4d249670fa82f2a0f7f17ee4b7bLaszlo Hordos # only 0 and 1 are widely recognized as exit values
bf3adaa7953ef4d249670fa82f2a0f7f17ee4b7bLaszlo Hordos # so change the exit value to 1
bf3adaa7953ef4d249670fa82f2a0f7f17ee4b7bLaszlo Hordos exit 1;
bf3adaa7953ef4d249670fa82f2a0f7f17ee4b7bLaszlo Hordos}
bf3adaa7953ef4d249670fa82f2a0f7f17ee4b7bLaszlo Hordos