lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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" <axkibe@gmail.com>
Sent: 12 July 2014 21:27
To: "Lua mailing list" <lua-l@lists.lua.org>
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" )



On Sat, Jul 12, 2014 at 10:47 AM, Xavier Wang <weasley.wx@gmail.com> wrote:
Hi,

I have found this archine:
http://lua-users.org/lists/lua-l/2006-09/msg00478.html

But, now, goto is a keyword for Lua, So the goto =goto is not work. Is
there other ways to make a Lua source file both a valid batch file?

--
regards,
Xavier Wang.