Re: bug in lua.c (Lua-5.0) while embedding the interpreter into bash-2.05
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: bug in lua.c (Lua-5.0) while embedding the interpreter into bash-2.05
- From: "Weiguang Shi" <wgshizz@...>
- Date: Fri, 9 Mar 2007 00:48:41 -0800
Thank you! And sorry for calling it a bug. Will check out luabash soon.
I just put the whole interpreter as a builtin (called lexec) to bash
(and later zsh)
so that lua code maintains its state inside bash script, e.g.,
$ lexec -e "a=1"
$ ls
$ ...
$ lexec -e "a=a+1"
$ pwd
$ ...
$ lexec -e "print(a)"
2
This way, I can create scripts that inter-mix bash and Lua code with one
Lua machine running from start to finish.
Wei
On 3/9/07, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> I've fixed the problem by calloc() a bigger piece of memory (just 4
> bytes bigger) than necessary for argv[] instead of malloc() for the
> exact amount of memory, i.e., argc*sizeof(char *).
I gather you're running the Lua interpreter via exec (or its variants) from
bash...
(BTW, are you aware of Lua Bash: http://freshmeat.net/projects/luabash/ ?)
Your fix is correct but I think you missunderstand the requirements on argv:
it's an array with argc+1 positions, the last one being NULL. So, you need
to malloc argc+1 positions for argv and set the last one to NULL before
exec'ing an external program.
Here are two references I found:
http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html
http://www-ccs.ucsd.edu/c/lib_over.html (search for main)
--lhf