lua-users home
lua-l archive

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


On Thu, Dec 20, 2012 at 12:41 AM, Grizzly Bear <6grizzlybear@gmail.com> wrote:
> My script, a.lua, starts with
>       #!/usr/local/bin/lua
>
> as the first line, i.e., using the interpreter coming with lua-5.1.5,
> how can I make the script return a value to indicate success or failure?
>
> That is, I'd like to do under bash
>      $ if ./a.lua; then echo "success"; fi
>
> Thanks.
> Wei

Use os.exit(n) in Lua and the $? variable in Bash:

$ lua5.1 -e 'os.exit(42)'; echo $?
42

or write all of the logic in a Lua script. ;-)


-- 
Sent from my Game Boy.