lua-users home
lua-l archive

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


Am 05.04.2014 20:43 schröbte tonyp@acm.org:

(Does anyone see any possibility of this method not working in all
possible cases, e.g., certain corner cases it would fail?)

From: Kevin Martin
Sent: Saturday, April 05, 2014 6:56 PM
To: tonyp@acm.org
Subject: Fwd: How to tell if running script directly?

  If some code is called through require, then the chunk has the name
given to require as it's first argument, if executed, there are no
arguments to the chunk.

Unless you have commandline arguments which in addition to the global `arg` table also end up in `...` ...


  So, for testing, I do

  local requirename = …
  if requirename then
  return moduletable
  end


Philipp