]> granicus.if.org Git - vim/commitdiff
patch 8.0.0450: v:progpath is not reliably set v8.0.0450
authorBram Moolenaar <Bram@vim.org>
Sun, 12 Mar 2017 17:38:02 +0000 (18:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 12 Mar 2017 17:38:02 +0000 (18:38 +0100)
Problem:    v:progpath is not reliably set.
Solution:   Read /proc/self/exe if possible. (idea by Michal Grochmal)
            Also fixes missing #if.

src/config.h.in
src/main.c
src/version.c

index 49ed596f47649fd8c6ea711770793666d1717835..a9bcf1ef33b5f9ca5d012cd1989ac1c73561df2d 100644 (file)
 /* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */
 #undef HAVE_FD_CLOEXEC
 
+/* Define if /proc/self/exe can be read */
+#undef HAVE_PROC_SELF_EXE
+
 /* Define if you want Cygwin to use the WIN32 clipboard, not compatible with X11*/
 #undef FEAT_CYGWIN_WIN32_CLIPBOARD
 
index f96bca99d8a7f379f7b635cfbebf6dfca809ace9..aa5a1a20c354f985e501b11aa0a12a2089e530a9 100644 (file)
@@ -3539,16 +3539,27 @@ set_progpath(char_u *argv0)
 {
     char_u *val = argv0;
 
+# ifdef HAVE_PROC_SELF_EXE
+    char    buf[PATH_MAX + 1];
+    ssize_t len;
+
+    len = readlink("/proc/self/exe", buf, PATH_MAX);
+    if (len > 0)
+    {
+       buf[len] = NUL;
+       val = (char_u *)buf;
+    }
+# else
     /* A relative path containing a "/" will become invalid when using ":cd",
      * turn it into a full path.
      * On MS-Windows "vim" should be expanded to "vim.exe", thus always do
      * this. */
-# ifdef WIN32
+#  ifdef WIN32
     char_u *path = NULL;
 
     if (mch_can_exe(argv0, &path, FALSE) && path != NULL)
        val = path;
-# else
+#  else
     char_u buf[MAXPATHL];
 
     if (!mch_isFullName(argv0))
index 54df7061c7d210208aaccaea7d4830d41ff515cd..257cba121133cdd8e6c778b44a5272bf47616a92 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    450,
 /**/
     449,
 /**/