[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: using 'return' to halt an executable Lua script
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sat, 15 Sep 2018 09:12:12 +0200
Op Vr., 14 Sep. 2018 om 22:24 het Joseph Manning <manning@cs.ucc.ie> geskryf:
> #!/usr/bin/env lua5.3
>
> if #arg ~= 2 then
> print( arg[ 0 ] .. " : two parameters expected" )
> return
> end
>
> -- continue normal processing with two parameters
> ...
> ...
>
> My question is about the use of 'return' to halt the script.
>
> Is this totally valid? Yes, it seems to work fine in practice,
> but I have not seen any explicit confirmation or examples of its use
> in either the Lua Reference Manual or Pil4 or elsewhere.
Well, it would be very strange if "lua xxx.lua" had a mechanism for
running a file different from "dofile", and in the case of the latter
the manual does say
Opens the named file and executes its contents as a Lua chunk. ...
Returns all values returned by the chunk.