mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 12:28:13 -04:00
feat: check for tool link/copy before --tool
This prevents stuff like `mkdwarfs --tool=dwarfsck` from working.
This commit is contained in:
parent
d5955f06d7
commit
a83bea3852
@ -84,6 +84,18 @@ extern "C" const PfnDliHook __pfnDliFailureHook2 = delay_hook;
|
||||
#endif
|
||||
|
||||
int SYS_MAIN(int argc, sys_char** argv) {
|
||||
auto path = std::filesystem::path(argv[0]);
|
||||
|
||||
// first, see if we are called as a copy/hardlink/symlink
|
||||
|
||||
if (path.extension().string() == EXE_EXT) {
|
||||
if (auto it = functions.find(path.stem().string()); it != functions.end()) {
|
||||
return safe_main([&] { return it->second(argc, argv); });
|
||||
}
|
||||
}
|
||||
|
||||
// if not, see if we can find a --tool=... argument
|
||||
|
||||
if (argc > 1) {
|
||||
auto tool_arg = sys_string_to_string(argv[1]);
|
||||
if (tool_arg.starts_with("--tool=")) {
|
||||
@ -98,13 +110,7 @@ int SYS_MAIN(int argc, sys_char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
auto path = std::filesystem::path(argv[0]);
|
||||
|
||||
if (path.extension().string() == EXE_EXT) {
|
||||
if (auto it = functions.find(path.stem().string()); it != functions.end()) {
|
||||
return safe_main([&] { return it->second(argc, argv); });
|
||||
}
|
||||
}
|
||||
// nope, just print the help
|
||||
|
||||
using namespace folly::gen;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user