Hello Axel,
Can you tell me the cases you solve with all the "if"s you introduce in the bash part of your script?
What problems could I face with the following implementation?
::dummy::--[[
@lua.exe "%~dpf0" %*
@goto :EOF
]]
print ('hello lua')
Thanks for your help!
Alexandre
--- Original Message ---
From: "Axel Kittenberger" <
[email protected]>
Sent: 12 July 2014 21:27
To: "Lua mailing list" <
[email protected]>
Subject: Re: Is there a way to run Lua source as .bat file?
Consider following modification. It uses the different meanings of '::' as label on the one hand and as comment on the other to construct different contexts:
::dummy--[[
@echo off
set f=%0
if exist "%f%" goto run
set f=%0.bat
if exist "%f%" goto run
set f=%~f0
if exist "%f%" goto run
set f=%~$PATH:0
if exist "%f%" goto run
for %%d in (%path%) do if exist "%%d\%0" set
f=%%d\%0
if exist "%f%" goto run
for %%d in (%path%) do if exist "%%d\%0.bat" set
f=%%d\%0.bat
if exist "%f%" goto run
:run
lua52.exe "%f%" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto :EOF
::--]]::
print( "hello lua" )