aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorRory Nesbitt <ranesbitt@live.co.uk>2023-09-27 18:09:55 +0100
committerGitHub <noreply@github.com>2023-09-27 10:09:55 -0700
commita66b0fdfaa35715c832b98b8941cc5673505e0c2 (patch)
treec61ba5de9fcbcccb9209657cbe3013a0881a385d /src/nvim/fileio.c
parentbfdec5b0e71991ebc0a8ad7c12d39f7a9cc56f07 (diff)
downloadrneovim-a66b0fdfaa35715c832b98b8941cc5673505e0c2.tar.gz
rneovim-a66b0fdfaa35715c832b98b8941cc5673505e0c2.tar.bz2
rneovim-a66b0fdfaa35715c832b98b8941cc5673505e0c2.zip
feat: NVIM_APPNAME supports relative paths #25233
Problem: NVIM_APPNAME does not allow path separators in the name, so relative paths can't be used: NVIM_APPNAME="neovim-configs/first-config" nvim NVIM_APPNAME="neovim-configs/second-config" nvim Solution: Let NVIM_APPNAME be a relative path. Absolute paths are not supported. fix #23056 fix #24966
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 7ff3e0ec6e..7609eb12b4 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -3279,12 +3279,18 @@ static void vim_mktempdir(void)
char tmp[TEMP_FILE_PATH_MAXLEN];
char path[TEMP_FILE_PATH_MAXLEN];
char user[40] = { 0 };
+ char appname[40] = { 0 };
(void)os_get_username(user, sizeof(user));
// Usernames may contain slashes! #19240
memchrsub(user, '/', '_', sizeof(user));
memchrsub(user, '\\', '_', sizeof(user));
+ // Appname may be a relative path, replace slashes to make it name-like.
+ xstrlcpy(appname, get_appname(), sizeof(appname));
+ memchrsub(appname, '/', '%', sizeof(appname));
+ memchrsub(appname, '\\', '%', sizeof(appname));
+
// Make sure the umask doesn't remove the executable bit.
// "repl" has been reported to use "0177".
mode_t umask_save = umask(0077);
@@ -3298,7 +3304,6 @@ static void vim_mktempdir(void)
// "/tmp/" exists, now try to create "/tmp/nvim.<user>/".
add_pathsep(tmp);
- const char *appname = get_appname();
xstrlcat(tmp, appname, sizeof(tmp));
xstrlcat(tmp, ".", sizeof(tmp));
xstrlcat(tmp, user, sizeof(tmp));