[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to get the directory of the current executed file?
- From: Norman Clarke <norman@...>
- Date: Tue, 18 Jan 2011 17:07:34 +0100
On Fri, Jan 14, 2011 at 07:46, Tang Daogang <daogangtang@gmail.com> wrote:
>
>
> On Fri, Jan 14, 2011 at 2:28 PM, steve donovan <steve.j.donovan@gmail.com>
> wrote:
>>
>> On Fri, Jan 14, 2011 at 8:26 AM, steve donovan
>> <steve.j.donovan@gmail.com> wrote:
>> > The lfs module from LuaFileSystem is the best known method:
>>
>> Nah, scratch that - sorry I have not had my tea.
>>
>> You can look at arg[0] for the script name, and work from there.
>>
>> Or get the debug information:
>>
>> function script_path()
>> -- remember to strip off the starting @
>> return debug.getinfo(2, "S").source:sub(2)
>> end
>>
>> print(script_path())
>>
> The debug library seems works on that. Thank you. I find it.
Not sure if you found this already, but I think what you're looking
for is something more like:
debug.getinfo(1).source:match("@(.*)$")
which will give you the current file where the call to debug.getinfo
is being made, regardless of which file is actually being executed.