X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-lua%2Fmadmutt.c;fp=lib-lua%2Fmadmutt.c;h=dfcf0840cdee21ae63e9238abf4a0c87b3b55481;hp=31ee28a5af15f635d4fd9fc154031e26c912a936;hb=0840ecb90bb99da0d6b0c028ace977dd1932e6e1;hpb=88d22daa9c1316d5ccc4b4bb60d40cc96c767757;ds=sidebyside diff --git a/lib-lua/madmutt.c b/lib-lua/madmutt.c index 31ee28a..dfcf084 100644 --- a/lib-lua/madmutt.c +++ b/lib-lua/madmutt.c @@ -18,6 +18,10 @@ */ #include + +#include +#include + #include "lib-lua_priv.h" #include "../mutt.h" @@ -144,13 +148,13 @@ static const struct { */ #ifdef USE_HCACHE #if defined(HAVE_QDBM) - {"hcache_backend", "qdbm" }, + { "hcache_backend", "qdbm" }, #elif defined(HAVE_GDBM) - {"hcache_backend", "gdbm" }, + { "hcache_backend", "gdbm" }, #elif defined(HAVE_DB4) - {"hcache_backend", "db4" }, + { "hcache_backend", "db4" }, #else - {"hcache_backend", "unknown" }, + { "hcache_backend", "unknown" }, #endif /* ** .pp @@ -160,6 +164,27 @@ static const struct { #endif }; +static const char *madmutt_init_shell(void) +{ + struct passwd *pw = getpwuid(getuid()); + + if (pw) + return pw->pw_shell; + return getenv("SHELL") ?: "/bin/sh"; +} + +static const struct { + const char *k; + const char *(*f)(void); +} madmutt_module_vars2[] = { + { "shell", madmutt_init_shell }, + /* + ** .pp + ** Command to use when spawning a subshell. By default, the user's login + ** shell from \fT/etc/passwd\fP is used. + */ +}; + int luaopen_madmutt(lua_State *L) { int i; @@ -174,6 +199,11 @@ int luaopen_madmutt(lua_State *L) lua_setfield(L, -2, madmutt_module_vars[i].key); } + for (i = 0; i < countof(madmutt_module_vars2); i++) { + lua_pushstring(L, madmutt_module_vars2[i].f()); + lua_setfield(L, -2, madmutt_module_vars2[i].k); + } + lua_pushstring(L, "__index"); lua_pushvalue(L, -2); lua_settable(L, -3);