runtime(ftplugin): allow to exec if curdir is in PATH

In case the current directory is present as valid $PATH entry, it is OK
to call the program from it, even if vim curdir is in that same
directory.

(Without that patch, for instance, you will not be able to open .zip
files while your current directory is /bin)

closes: #13027

Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/autoload/gzip.vim b/runtime/autoload/gzip.vim
index ac9e37b..6d0bb13 100644
--- a/runtime/autoload/gzip.vim
+++ b/runtime/autoload/gzip.vim
@@ -11,7 +11,10 @@
   let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
   if !exists("s:have_" . name)
     " safety check, don't execute anything from the current directory
-    let f = fnamemodify(exepath(name), ":p:h") !=# getcwd()
+    let s:tmp_cwd = getcwd()
+    let f = (fnamemodify(exepath(name), ":p:h") !=# s:tmp_cwd
+          \ || (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) != -1 && s:tmp_cwd != '.'))
+    unlet s:tmp_cwd
     if !f
       echoerr "Warning: NOT executing " .. name .. " from current directory!"
     endif
diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim
index 0331a54..8b39c91 100644
--- a/runtime/autoload/zip.vim
+++ b/runtime/autoload/zip.vim
@@ -57,10 +57,15 @@
  let g:zip_extractcmd= g:zip_unzipcmd
 endif
 
-if fnamemodify(exepath(g:zip_unzipcmd), ":p:h") ==# getcwd()
+let s:tmp_cwd = getcwd()
+if (fnamemodify(exepath(g:zip_unzipcmd), ":p:h") ==# getcwd()
+          \ && (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) == -1 || s:tmp_cwd == '.'))
+ unlet s:tmp_cwd
  echoerr "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!"
  finish
 endif
+unlet s:tmp_cwd
+
 " ----------------
 "  Functions: {{{1
 " ----------------