From 650f67507f2718dec0d4282afea619cfe7a53305 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 26 Feb 2018 20:39:23 +0000 Subject: win32: move detection of file formats to stat(2) Move the code to detect shell scripts and binary executables from mingw_access to a separate function, has_exec_format. Call this function in do_lstat to decide whether to set the executable bits in the file mode. This will slow down stat but has a couple of advantages: - shell scripts are highlighted in ls output - the test applet can use stat(2) to detect executable files The new function is used to handle another corner case in spawnveq: binary executables without the usual .exe extension are only run by spawnve if the file name ends with '.'. Two minor changes: - file_is_win32_executable has been renamed add_win32_extension to clarify what it does - a call to file_is_executable has been removed from find_command in ash as it resulted in unhelpful error messages. --- libbb/executable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libbb') diff --git a/libbb/executable.c b/libbb/executable.c index 8e2f99732..76b10f790 100644 --- a/libbb/executable.c +++ b/libbb/executable.c @@ -77,7 +77,7 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp) return p; } #if ENABLE_PLATFORM_MINGW32 - else if ((w=file_is_win32_executable(p))) { + else if ((w=add_win32_extension(p))) { *PATHp = n; free(p); return w; -- cgit v1.2.3-55-g6feb