{
const char *idx = luaL_checkstring(L, 2);
const char *val = luaL_checkstring(L, 3);
+ char buf[STRING];
switch (lua_which_token(idx, -1)) {
default:
case LTK_SENDMAIL:
case LTK_SHELL:
+ _mutt_expand_path(buf, sizeof(buf), val, 0);
+ val = buf;
break;
}
#endif
};
-static const char *madmutt_init_shell(void)
+static void madmutt_init_shell(char *buf, ssize_t len)
{
struct passwd *pw = getpwuid(getuid());
- if (pw)
- return pw->pw_shell;
- return getenv("SHELL") ?: "/bin/sh";
+ if (pw) {
+ m_strcpy(buf, len, pw->pw_shell);
+ _mutt_expand_path(buf, len, pw->pw_shell, 0);
+ } else {
+ m_strcpy(buf, len, getenv("SHELL") ?: "/bin/sh");
+ }
}
static const struct {
- const char *k;
- const char *(*f)(void);
+ const char *key;
+ void (*fun)(char *buf, ssize_t len);
} madmutt_module_vars2[] = {
{ "shell", madmutt_init_shell },
/*
}
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);
+ char buf[STRING];
+ (madmutt_module_vars2[i].fun)(buf, sizeof(buf));
+ lua_pushstring(L, buf);
+ lua_setfield(L, -2, madmutt_module_vars2[i].key);
}
lua_pushstring(L, "__index");