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?

  @lua.exe "%~dpf0" %*
  @goto :EOF

print ('hello lua')

Thanks for your help!


--- Original Message ---

From: "Axel Kittenberger" <>
Sent: 12 July 2014 21:27
To: "Lua mailing list" <>
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:

@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
if exist "%f%" goto run
for %%d in (%path%) do if exist "%%d\%0.bat" set
if exist "%f%" goto 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 <> wrote:

I have found this archine:

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?

Xavier Wang.