I am writing a script testmodule.lua and want to check that if this file is imported/required from another script or directly started by lua testmodule.lua.
If it is directly started by command line I can do some test or run a main function, otherwise just export some function and do nothing.
Python has a __name__ statement:
if __name__ == '__main__':
main_entry()
Is there something similar in lua ??
It is useful to write a shell util in a single file, which can be run directly and imported by other lua scripts. But when some script import this file, I don't like main function to be called.