From 635569961e38a5a9728fa4a0dee6d4f5fda68025 Mon Sep 17 00:00:00 2001 From: Cormac Shannon <> Date: Tue, 17 Mar 2026 18:59:49 +0000 Subject: [PATCH] Fix(lua.c): Accept config.lua/.lush files --- lua.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lua.c b/lua.c index 0e6485c2..9fd50c16 100644 --- a/lua.c +++ b/lua.c @@ -4,6 +4,7 @@ ** See Copyright Notice in lua.h */ +#include // this is unix/linux only #define lua_c #include "lprefix.h" @@ -767,7 +768,9 @@ static void run_config_dir (lua_State *L, const char *dirpath) { /* collect .lua filenames */ while ((entry = readdir(d)) != NULL && count < 256) { size_t len = strlen(entry->d_name); - if (len > 4 && strcmp(entry->d_name + len - 4, ".lua") == 0) + if (len > 4 && ( + strcmp(entry->d_name + len - 4, ".lua") == 0 || + strcmp(entry->d_name + len - 5, ".lush") == 0)) names[count++] = strdup(entry->d_name); } closedir(d); @@ -788,20 +791,24 @@ static void run_config_dir (lua_State *L, const char *dirpath) { static void handle_lushconfig (lua_State *L) { char configdir[PATH_MAX]; char path[PATH_MAX]; + static const char *extensions[] = {"lua", "lush", NULL }; + int i; if (get_config_dir(configdir, sizeof(configdir)) == NULL) return; /* no HOME or XDG_CONFIG_HOME — skip silently */ - /* 1. Run ~/.config/lush/config if it exists */ - snprintf(path, sizeof(path), "%s/config", configdir); - if (access(path, R_OK) == 0) - dofile(L, path); /* errors are reported but not fatal */ - + /* 1. Run config.lua, or config.lush if any exist */ + for (i = 0; extensions[i] != NULL; i++) { + snprintf(path, sizeof(path), "%s/config.%s", configdir, extensions[i]); + if (access(path, R_OK) == 0) + dofile(L, path); /* errors are reported but not fatal */ + } /* 2. Run config.d/ lua files in sorted order */ snprintf(path, sizeof(path), "%s/config.d", configdir); run_config_dir(L, path); } + /* }================================================================== */