From f5783ef14f9ad96ae483f16e639953d0212ca7d0 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 28 Feb 2018 19:57:02 +0000 Subject: win32: additional improvements to handling of executables Consistent processing of file extensions, as described in the previous commit, has been applied to the 'which' applet and the functions find_executable and mingw_spawn_interpreter. In spawnveq check that the file to be executed exists and is executable, and ensure that it won't have any extensions added by spawnve. It's intended that all files passed to spawnve should have their names fully specified. If this isn't the case the tests here will cause errors which will need to be fixed. --- libbb/executable.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libbb') diff --git a/libbb/executable.c b/libbb/executable.c index 76b10f790..aec829945 100644 --- a/libbb/executable.c +++ b/libbb/executable.c @@ -66,23 +66,23 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp) p[0] ? p : ".", /* handle "::" case */ filename ); - ex = file_is_executable(p); #if ENABLE_PLATFORM_MINGW32 if (n) *n++ = sep; #else if (n) *n++ = ':'; #endif - if (ex) { - *PATHp = n; - return p; - } #if ENABLE_PLATFORM_MINGW32 - else if ((w=add_win32_extension(p))) { + if ((w=add_win32_extension(p))) { *PATHp = n; free(p); return w; } #endif + ex = file_is_executable(p); + if (ex) { + *PATHp = n; + return p; + } free(p); p = n; } /* on loop exit p == NULL */ -- cgit v1.2.3-55-g6feb