From 33ed66ce0a8c32b47e3b4735edad81d51a8253a2 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Fri, 2 Aug 2024 14:14:21 +0200 Subject: [PATCH] feat(universal-binary): allow version suffix on symlinks/copies --- src/universal.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/universal.cpp b/src/universal.cpp index acc5fb07..42084d49 100644 --- a/src/universal.cpp +++ b/src/universal.cpp @@ -68,6 +68,18 @@ int SYS_MAIN(int argc, sys_char** argv) { if (auto it = functions.find(stem); it != functions.end()) { return safe_main([&] { return it->second(argc, argv); }); } + + // see if the stem has an appended version and try removing that + if (auto pos = stem.find_first_of('-'); pos != std::string::npos && + pos + 1 < stem.size() && + std::isdigit(stem[pos + 1])) { + if (auto it = functions.find(stem.substr(0, pos)); + it != functions.end()) { + std::cerr << "running " << stem << " as " << stem.substr(0, pos) + << "\n"; + return safe_main([&] { return it->second(argc, argv); }); + } + } } // if not, see if we can find a --tool=... argument