diff --git a/src/win/path_util.cc b/src/win/path_util.cc index 764c0330..c162e803 100644 --- a/src/win/path_util.cc +++ b/src/win/path_util.cc @@ -55,7 +55,7 @@ std::wstring get_shell_path(std::wstring filename) { std::wstring shellpath; if (file_exists(filename)) { - return shellpath; + return filename; } wchar_t* buffer_ = new wchar_t[MAX_ENV]; diff --git a/src/windowsTerminal.test.ts b/src/windowsTerminal.test.ts index 5aa6c843..a5f9eb18 100644 --- a/src/windowsTerminal.test.ts +++ b/src/windowsTerminal.test.ts @@ -239,6 +239,28 @@ if (process.platform === 'win32') { }); }); + describe('relative file', () => { + it('should resolve a file that also exists in the process cwd', function (done) { + this.timeout(10000); + const originalCwd = process.cwd(); + process.chdir(path.join(process.env.windir!, 'System32')); + let term: WindowsTerminal; + try { + term = new WindowsTerminal('cmd.exe', '/C echo hello', { useConptyDll }); + } finally { + process.chdir(originalCwd); + } + let result = ''; + term.on('data', (data) => { + result += data; + }); + term.on('exit', () => { + assert.ok(result.indexOf('hello') >= 0); + done(); + }); + }); + }); + describe('connect failure', () => { it('should emit exit instead of an uncaught exception when CreateProcessW fails', function (done) { this.timeout(10000);