Call realpath on the source file to match -f on the command line, GitHub

issue 4180.
This commit is contained in:
nicm 2024-10-12 08:20:32 +00:00
parent 2d8b6fcf23
commit f8b56fdc3f

View File

@ -122,6 +122,14 @@ cmd_source_file_done(struct client *c, const char *path, int error,
static void static void
cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path) cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
{ {
char resolved[PATH_MAX];
if (realpath(path, resolved) == NULL) {
log_debug("%s: realpath(\"%s\") failed: %s", __func__,
path, strerror(errno));
} else
path = resolved;
log_debug("%s: %s", __func__, path); log_debug("%s: %s", __func__, path);
cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1, cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1,
sizeof *cdata->files); sizeof *cdata->files);