diff options
author | Ron Yorston <rmy@pobox.com> | 2018-02-26 20:39:23 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-02-26 20:39:23 +0000 |
commit | 650f67507f2718dec0d4282afea619cfe7a53305 (patch) | |
tree | 82e523133f961e8337f42765307b63dc737f2580 /shell | |
parent | fcb5c968bef6c4fd234e000aaeaa160ac1d16f11 (diff) | |
download | busybox-w32-650f67507f2718dec0d4282afea619cfe7a53305.tar.gz busybox-w32-650f67507f2718dec0d4282afea619cfe7a53305.tar.bz2 busybox-w32-650f67507f2718dec0d4282afea619cfe7a53305.zip |
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.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/shell/ash.c b/shell/ash.c index 30f3b558b..7dec5dfc7 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -13654,7 +13654,7 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
13654 | if (act & DO_ABS) { | 13654 | if (act & DO_ABS) { |
13655 | while (stat(name, &statb) < 0 | 13655 | while (stat(name, &statb) < 0 |
13656 | #if ENABLE_PLATFORM_MINGW32 | 13656 | #if ENABLE_PLATFORM_MINGW32 |
13657 | && (fullname=file_is_win32_executable(name)) == NULL | 13657 | && (fullname=add_win32_extension(name)) == NULL |
13658 | #endif | 13658 | #endif |
13659 | ) { | 13659 | ) { |
13660 | #ifdef SYSV | 13660 | #ifdef SYSV |
@@ -13798,10 +13798,6 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
13798 | e = errno; | 13798 | e = errno; |
13799 | goto loop; | 13799 | goto loop; |
13800 | } | 13800 | } |
13801 | if (!file_is_executable(fullname)) { | ||
13802 | e = ENOEXEC; | ||
13803 | goto loop; | ||
13804 | } | ||
13805 | } | 13801 | } |
13806 | } | 13802 | } |
13807 | #else | 13803 | #else |