Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mingw: when trying to execute non-existing /bin/<cmd>, try an applet
If BusyBox is installed as /mingw64/bin/busybox.exe, and there are no Unix-y tools installed (not even a /bin/sh), it is pretty clear what we want BusyBox to do when a script asks to execute /bin/sh <args>: BusyBox should pass those args to its own ash. So what we do is to detect when /bin/<command> does not exist and <command> is an applet, and replace /bin/<command> by BusyBox' own executable path. This works as long as argv[0] still refers to the <command>. However, when we wanted to execute /bin/sh and argv[0] referred to a script's path, we need to be careful to shift "sh" into argv so that BusyBox will know to what applet it is expected to pass the arguments. To accomplish that, we simply redo the argv -> wargv conversion (it is by far the most robust way). Technically, that latter case does not even happen right now, because we only ever call scripts with argv[0] being set to "sh" due to the way parse_interpreter simply strips away the path from the interpreter. But this is the current state of affairs, and it is better to safeguard, especially when it is this easy. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
- Loading branch information