-
Notifications
You must be signed in to change notification settings - Fork 4
/
runperl.bat
81 lines (71 loc) · 2.33 KB
/
runperl.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@echo off
rem
rem Copyright (C) 2001-2024 Graeme Walker <[email protected]>
rem
rem This program is free software: you can redistribute it and/or modify
rem it under the terms of the GNU General Public License as published by
rem the Free Software Foundation, either version 3 of the License, or
rem (at your option) any later version.
rem
rem This program is distributed in the hope that it will be useful,
rem but WITHOUT ANY WARRANTY; without even the implied warranty of
rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
rem GNU General Public License for more details.
rem
rem You should have received a copy of the GNU General Public License
rem along with this program. If not, see <http://www.gnu.org/licenses/>.
rem ===
rem
rem runperl.bat
rem
rem Runs "perl %1" and checks for an output file %2.
rem
rem The perl program is located using "ftype" or the PATH or c:/perl/bin.
rem Using ftype is more likely to find ActiveState perl rather than
rem MSYS or Cygwin. For ActiveState the perl script sees a $^O value
rem of "MSWin32".
rem
@rem find perl using ftype
SET RUNPERL_PERL=
for /f "tokens=2 delims== " %%I in ('cmd /c "ftype perl 2>NUL:"') do set RUNPERL_PERL=%%~I
IF "%RUNPERL_PERL%"=="" goto no_ftype
IF NOT EXIST "%RUNPERL_PERL%" goto no_ftype
@rem run the ftype perl
IF EXIST %2 del /f %2
for /f "tokens=2 delims== " %%I in ('cmd /c "ftype perl 2>NUL:"') do %%I %1 %3 %4 %5
goto done
@rem find perl on the path
:no_ftype
where /q perl
if errorlevel 1 goto no_path
@rem run perl on the path
IF EXIST %2 del /f %2
cmd /c perl %1 %3 %4 %5
goto done
@rem try c:\perl\bin
:no_path
c:\perl\bin\perl.exe -e "exit 99" 2>NUL:
if not errorlevel 99 goto no_c_perl
c:\perl\bin\perl.exe %1 %3 %4 %5
goto done
@rem try ..\perl-bin\bin
:no_c_perl
..\perl-bin\bin\perl.exe -e "exit 99" 2>NUL:
if not errorlevel 99 goto fail_no_perl
..\perl-bin\bin\perl.exe %1 %3 %4 %5
goto done
@rem after running perl check for the touchfile
:done
IF NOT EXIST "%2" goto fail_no_touchfile
echo done
goto end
@rem error if no perl
:fail_no_perl
echo error: failed to find perl: please install ActiveState perl
goto end
@rem error if no touchfile
:fail_no_touchfile
echo error: perl command failed: no output file created
goto end
:end
if "%RUNPERL_NOPAUSE%"=="" pause