Skip to content

Commit 5ac3508

Browse files
committed
Added a check to verify if the script path is absolute or not.
1 parent 1f0b622 commit 5ac3508

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/lua/llua.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,21 @@ inline bool file_exists(const char *path) {
267267
void llua_load(const char *script) {
268268
int error;
269269

270-
std::filesystem::path path = to_real_path(script);
270+
std::filesystem::path path;
271+
std::filesystem::path script_path(script);
272+
273+
if (!script_path.is_absolute()) {
274+
auto cfg_path = std::filesystem::path(to_real_path(XDG_CONFIG_FILE));
275+
auto cfg_dir = cfg_path.parent_path();
276+
277+
// prepend the config directory to the script path
278+
auto full = cfg_dir / script_path;
279+
path = to_real_path(full.c_str());
280+
}
281+
else {
282+
// Already an absolute path
283+
path = to_real_path(script);
284+
}
271285

272286
if (!file_exists(path.c_str())) {
273287
bool found_alternative = false;

0 commit comments

Comments
 (0)