lua-users home
lua-l archive

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

For Unix, not all Lua installations result in Lua being placed in
/usr/local/bin/lua.  For maximum portability, I suggest that one start
Unix scripts with the line:

   #! /usr/bin/env lua

Please make a note of this trick in Section 8 of the Lua documentation
titled "Lua Stand-alone".

The bytecode interpreter crashes on bytecode files that start with the
string "#! /usr/bin/env lua".  This means that bytecode cannot be made
executable using the usual Unix trick.  Please change the Lua
interpreter so that it strips the first line in a file if it begins
with sharp sign no matter if it is a Lua program as text, or the
result of bytecode compilation.

What is the file extension people normally use for Lua bytecode files?


bash-2.01$ uname -a
Linux 2.2.16-3RCF #1 Thu Jul 27 13:22:01 EDT 2000 i686 unknown
bash-2.01$ lua -v
Lua 4.0  Copyright (C) 1994-2000 TeCGraf, PUC-Rio
bash-2.01$ cat one.lua 
print(not nil)
bash-2.01$ cat Makefile


.SUFFIXES: .lbc .lua

	luac -o $@ $(LUAFLAGS)$<

	echo '#! /usr/bin/env lua' | cat - $< > $@
	chmod +x $@

all:	$(TARGETS)

	-rm $(TARGETS) *.lbc
bash-2.01$ make
luac -o one.lbc one.lua
echo '#! /usr/bin/env lua' | cat - one.lbc > one
chmod +x one
rm one.lbc
bash-2.01$ ./one
error: invalid control char;
  last token read: `0x1B' at line 2 in file `./one'