# HG changeset patch # User Bram Moolenaar # Date 1563973206 -7200 # Node ID f1fd0b0b335c4a10f8ff885cb315e1e502115464 # Parent 63ea3a9ba8cb7395d25ce58f6518f50bfe2a9d98 patch 8.1.1740: exepath() doesn't work for "bin/cat" commit https://github.com/vim/vim/commit/d08b8c4c04db9433340df38d21f0e26878f28421 Author: Bram Moolenaar Date: Wed Jul 24 14:59:45 2019 +0200 patch 8.1.1740: exepath() doesn't work for "bin/cat" Problem: Exepath() doesn't work for "bin/cat". Solution: Check for any path separator. (Daniel Hahler, closes https://github.com/vim/vim/issues/4724, closes #4710) diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3058,8 +3058,7 @@ f_executable(typval_T *argvars, typval_T char_u *name = tv_get_string(&argvars[0]); /* Check in $PATH and also check directly if there is a directory name. */ - rettv->vval.v_number = mch_can_exe(name, NULL, TRUE) - || (gettail(name) != name && mch_can_exe(name, NULL, FALSE)); + rettv->vval.v_number = mch_can_exe(name, NULL, TRUE); } static garray_T redir_execute_ga; diff --git a/src/os_unix.c b/src/os_unix.c --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3103,12 +3103,11 @@ mch_can_exe(char_u *name, char_u **path, /* When "use_path" is false and if it's an absolute or relative path don't * need to use $PATH. */ - if (!use_path || mch_isFullName(name) || (name[0] == '.' - && (name[1] == '/' || (name[1] == '.' && name[2] == '/')))) + if (!use_path || gettail(name) != name) { /* There must be a path separator, files in the current directory * can't be executed. */ - if (gettail(name) != name && executable_file(name)) + if ((use_path || gettail(name) != name) && executable_file(name)) { if (path != NULL) { diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -990,6 +990,14 @@ func Test_Executable() elseif has('unix') call assert_equal(1, executable('cat')) call assert_equal(0, executable('nodogshere')) + + " get "cat" path and remove the leading / + let catcmd = exepath('cat')[1:] + new + lcd / + call assert_equal(1, executable(catcmd)) + call assert_equal('/' .. catcmd, exepath(catcmd)) + bwipe endif endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -778,6 +778,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1740, +/**/ 1739, /**/ 1738,