-// Copyright (C) 2021-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2025 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
std::string
add_exe_suffix(const std::string& program)
{
- std::string ext = util::to_lowercase(fs::path(program).extension().string());
- if (ext == ".exe" || ext == ".bat" || ext == ".cmd" || ext == ".sh") {
- return program;
- } else {
- return program + ".exe";
- }
+ return fs::path(program).has_extension() ? program : program + ".exe";
}
fs::path
-// Copyright (C) 2021-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2025 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
// --- Interface ---
-// Add ".exe" suffix to `program` if it doesn't already end with ".exe", ".bat",
-// ".cmd" or ".sh".
+// Add ".exe" suffix to `program` if it doesn't already have an extension.
std::string add_exe_suffix(const std::string& program);
// Return a new path with `extension` added to `path` (keeping any existing