Lua: include file in same directory

I am using IMAPFilter and I would like to save my global configuration to a public repository , keeping the local (and secret) configuration in a separate file. So I run imapfilterfrom some directory, it includes ~ / .imapfilter / config.lua, and it should include. / config _local.lua, where "." this is the config.lua directory, not the shell $PWDor location imapfilter. Here is what I have tried so far:

require "config_local"
require "./config_local"

Edit: the absolute path works:

dofile(os.getenv("HOME") .. "/.imapfilter/config_local.lua")

Not very elegant, but at least it is compatible with cron.

+3
source share
1 answer

Add a path to package.path.

Something like this (not verified):

package.path = package.path .. ";" .. os.getenv("HOME") .. "/.imapfilter/?.lua"
+5
source

All Articles