Skip to content

Commit 8ec6f27

Browse files
committed
Adjusted roscon.bat to match what's advertised in its REMs;
Added a shebang to the stub, making the PHAR potentially directly executable on UNIX.
1 parent ef9401e commit 8ec6f27

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

scripts/roscon.bat

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
@echo off
2-
:: Prefer PHP binary in the following order:
3-
:: 1. Whatever %PHPBIN% points to.
4-
:: 2. "php" from %cd% with one of %pathext% extensions.
5-
:: 3. "php" from a %path% path with one of %pathext% extensions.
6-
:: 4. Whatever %PHP_PEAR_PHP_BIN% points to.
7-
::
8-
:: Once a binary is found, a file with the same name as this one
9-
:: will be ran. Prefered extensions are no extension and ".php"
10-
:: in this order.
11-
::
2+
REM Prefer PHP binary in the following order:
3+
REM 1. Whatever %PHPBIN% points to.
4+
REM 2. "php" from %cd% with one of %pathext% extensions.
5+
REM 3. "php" from a %path% path with one of %pathext% extensions.
6+
REM 4. Whatever %PHP_PEAR_PHP_BIN% points to.
7+
REM
8+
REM Once a binary is found, a file is looked for at the %PHPFILE% environment
9+
REM variable (not intendend to be overriden).
10+
REM Fallbacks to a file with the same name as this one.
11+
REM Prefered extensions are ".php" and then no extension.
12+
REM
13+
goto SET_BIN
14+
:PHP_ERR
15+
echo PHP interpreter not found. Please set the %%PHPBIN%% or %%PHP_PEAR_PHP_BIN%% environment variable to one, or add one to your %%PATH%%.
16+
goto DONE
17+
:FILE_ERR
18+
echo The file to be ran was not found. It should be at either "%~d0%~p0%~n0.php" or "%~d0%~p0%~n0".
19+
goto DONE
20+
:SET_BIN
1221
if "%PHPBIN%" == "" set PHPBIN=php
13-
if exist "%PHPBIN%" goto SET_FILE
14-
if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_BIN
15-
goto PHP_ERR
16-
:USE_PEAR_BIN
22+
where /q %PHPBIN%
23+
if %ERRORLEVEL% == 0 goto SET_FILE
24+
if "%PHP_PEAR_PHP_BIN%" == "" goto PHP_ERR
25+
where /q "%PHP_PEAR_PHP_BIN%"
26+
if %ERRORLEVEL% neq 0 goto PHP_ERR
1727
set PHPBIN=%PHP_PEAR_PHP_BIN%
18-
if exist "%PHP_PEAR_PHP_BIN%" goto SET_FILE
19-
goto PHP_ERR
2028
:SET_FILE
21-
if "%PHPFILE%" == "" set PHPFILE=%~d0%~p0%~n0
22-
if exist "%PHPFILE%" goto RUN
23-
set PHPFILE=%~d0%~p0%~n0.php
29+
if "%PHPFILE%" == "" set PHPFILE=%~d0%~p0%~n0.php
2430
if exist "%PHPFILE%" goto RUN
25-
goto FILE_ERR
31+
set PHPFILE=%~d0%~p0%~n0
32+
if not exist "%PHPFILE%" goto FILE_ERR
2633
:RUN
2734
"%PHPBIN%" "%PHPFILE%" %*
28-
goto DONE
29-
:PHP_ERR
30-
echo PHP interpreter not found. Please set the %%PHPBIN%% or %%PHP_PEAR_PHP_BIN%% environment variable to one, or add a PHP interpreter to your %%PATH%%.
31-
goto DONE
32-
:FILE_ERR
33-
echo The file to be ran was not found. It should be in the same folder, and either have a ".php" extension, or no extension at all.
3435
:DONE

stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env php
12
<?php
23

34
/**

0 commit comments

Comments
 (0)