diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-01 23:21:38 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-02 01:28:11 +0200 |
commit | c7039fd0d3f6f5d7c8699fd88095e100f0754e59 (patch) | |
tree | 7ac75bbe0a92a3d17fe2880d7bb2b52f58127830 | |
parent | 70a0a12b5397b8b787a3196e9196f5fdbf979cf6 (diff) | |
download | rneovim-c7039fd0d3f6f5d7c8699fd88095e100f0754e59.tar.gz rneovim-c7039fd0d3f6f5d7c8699fd88095e100f0754e59.tar.bz2 rneovim-c7039fd0d3f6f5d7c8699fd88095e100f0754e59.zip |
test: "$PATHEXT=::"
-rw-r--r-- | src/nvim/os/fs.c | 8 | ||||
-rw-r--r-- | test/functional/eval/executable_spec.lua | 19 | ||||
-rw-r--r-- | test/functional/eval/exepath_spec.lua | 2 |
3 files changed, 18 insertions, 11 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 91ed639a1b..8d9de1253e 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -297,9 +297,9 @@ static bool is_executable(const char *name, char_u **abspath) } #ifdef WIN32 -/// Checks if file `name` is executable under one of these conditions: -/// - if the file extension is in $PATHEXT and `name` is executable -/// - if the result of any $PATHEXT extension appended to `name` is executable +/// Checks if file `name` is executable under any of these conditions: +/// - extension is in $PATHEXT and `name` is executable +/// - result of any $PATHEXT extension appended to `name` is executable static bool is_executable_ext(char *name, char_u **abspath) FUNC_ATTR_NONNULL_ARG(1) { @@ -318,7 +318,7 @@ static bool is_executable_ext(char *name, char_u **abspath) if (is_executable(name, abspath)) { return true; } - // Skip the extension. + // Skip it. ext++; continue; } diff --git a/test/functional/eval/executable_spec.lua b/test/functional/eval/executable_spec.lua index efce0745ad..6a95128a4d 100644 --- a/test/functional/eval/executable_spec.lua +++ b/test/functional/eval/executable_spec.lua @@ -136,7 +136,14 @@ describe('executable() (Windows)', function() eq(1, call('executable', '.\\test_executable_zzz')) end) - it('returns 1 for any existing filename, when a Unix-shell like \'shell\'', function() + it("with weird $PATHEXT", function() + clear({env={PATHEXT=';'}}) + eq(0, call('executable', '.\\test_executable_zzz')) + clear({env={PATHEXT=';;;.zzz;;'}}) + eq(1, call('executable', '.\\test_executable_zzz')) + end) + + it("unqualified filename, Unix-style 'shell'", function() clear({env={PATHEXT=''}}) command('set shell=sh') for _,ext in ipairs(exts) do @@ -145,7 +152,7 @@ describe('executable() (Windows)', function() eq(1, call('executable', 'test_executable_zzz.zzz')) end) - it('returns 1 for any existing path, when a Unix-shell like \'shell\' (backslashes)', function() + it("relative path, Unix-style 'shell' (backslashes)", function() clear({env={PATHEXT=''}}) command('set shell=bash.exe') for _,ext in ipairs(exts) do @@ -156,7 +163,7 @@ describe('executable() (Windows)', function() eq(1, call('executable', './test_executable_zzz.zzz')) end) - it('returns 1 for any existing filename, when $PATHEXT contain dot itself', function() + it('unqualified filename, $PATHEXT contains dot', function() clear({env={PATHEXT='.;.zzz'}}) for _,ext in ipairs(exts) do eq(1, call('executable', 'test_executable_'..ext..'.'..ext)) @@ -169,7 +176,7 @@ describe('executable() (Windows)', function() eq(1, call('executable', 'test_executable_zzz.zzz')) end) - it('returns 1 for any existing path, when $PATHEXT contain dot itself (backslashes)', function() + it('relative path, $PATHEXT contains dot (backslashes)', function() clear({env={PATHEXT='.;.zzz'}}) for _,ext in ipairs(exts) do eq(1, call('executable', '.\\test_executable_'..ext..'.'..ext)) @@ -179,12 +186,12 @@ describe('executable() (Windows)', function() eq(1, call('executable', './test_executable_zzz.zzz')) end) - it('ignore case of extension', function() + it('ignores case of extension', function() clear({env={PATHEXT='.ZZZ'}}) eq(1, call('executable', 'test_executable_zzz.zzz')) end) - it('file is not found by relative path from $PATH', function() + it('relative path does not search $PATH', function() clear({env={PATHEXT=''}}) eq(0, call('executable', './System32/notepad.exe')) eq(0, call('executable', '.\\System32\\notepad.exe')) diff --git a/test/functional/eval/exepath_spec.lua b/test/functional/eval/exepath_spec.lua index 50aa412867..10a11aeacc 100644 --- a/test/functional/eval/exepath_spec.lua +++ b/test/functional/eval/exepath_spec.lua @@ -5,7 +5,7 @@ local eq, clear, call, iswin = describe('exepath() (Windows)', function() if not iswin() then return end -- N/A for Unix. - it('append extension, even if omit extension', function() + it('append extension if omitted', function() local filename = 'cmd' local pathext = '.exe' clear({env={PATHEXT=pathext}}) |