From 38cf620f4e214775f78346bd53bdb8eec8173242 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 12 Oct 2024 08:20:32 +0000 Subject: [PATCH] Call realpath on the source file to match -f on the command line, GitHub issue 4180. --- usr.bin/tmux/cmd-source-file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/usr.bin/tmux/cmd-source-file.c b/usr.bin/tmux/cmd-source-file.c index 83c29bf6544..01e4a8a8ae8 100644 --- a/usr.bin/tmux/cmd-source-file.c +++ b/usr.bin/tmux/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-source-file.c,v 1.54 2023/09/15 06:31:49 nicm Exp $ */ +/* $OpenBSD: cmd-source-file.c,v 1.55 2024/10/12 08:20:32 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha @@ -122,6 +122,14 @@ cmd_source_file_done(struct client *c, const char *path, int error, static void 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); cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1, sizeof *cdata->files); -- 2.20.1