patch 8.1.0211: expanding a file name "~" results in $HOME
Problem: Expanding a file name "~" results in $HOME. (Aidan Shafran)
Solution: Change "~" to "./~" before expanding. (closes #3072)
diff --git a/src/eval.c b/src/eval.c
index ef25a3f..6034cd2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -9690,11 +9690,12 @@
*/
int
modify_fname(
- char_u *src, /* string with modifiers */
- int *usedlen, /* characters after src that are used */
- char_u **fnamep, /* file name so far */
- char_u **bufp, /* buffer for allocated file name or NULL */
- int *fnamelen) /* length of fnamep */
+ char_u *src, // string with modifiers
+ int tilde_file, // "~" is a file name, not $HOME
+ int *usedlen, // characters after src that are used
+ char_u **fnamep, // file name so far
+ char_u **bufp, // buffer for allocated file name or NULL
+ int *fnamelen) // length of fnamep
{
int valid = 0;
char_u *tail;
@@ -9724,8 +9725,8 @@
|| (*fnamep)[1] == '\\'
# endif
|| (*fnamep)[1] == NUL)
-
#endif
+ && !(tilde_file && (*fnamep)[1] == NUL)
)
{
*fnamep = expand_env_save(*fnamep);