lua-users home
lua-l archive

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


On Fri, Jan 23, 2015 at 02:21:58PM -0800, William Ahern wrote:
> My recently released runlua utility has an option to load and skip over any
> initial shell code in the file. But I just discovered a neat trick which
> obviates the need for such a feature.
> 
>   #!/bin/sh
>   _=[[
>   exec lua "$0" "$@"
>   ]]
>   print("Running", _VERSION)
>   print("Options", ...)
> 
> Probably others have figured this out, too, but it's new to me.

Rena posted nearly the same thing a few years ago:

http://lua-users.org/lists/lua-l/2012-05/msg00171.html

His example is also portable. It doesn't rely on anything unique to bash.