From 0fe933c57134823087f3a4b8b877b35b40de4d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20NIVET?= <5648584+mnivet@users.noreply.github.com> Date: Wed, 28 Jun 2023 10:17:02 +0200 Subject: [PATCH] Pass arguments by default if there is no custom arguments This is a fix of issue #7 --- shim/shim.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/shim/shim.cpp b/shim/shim.cpp index effceb7..799ff65 100644 --- a/shim/shim.cpp +++ b/shim/shim.cpp @@ -50,8 +50,6 @@ int wmain(int argc, wchar_t* argv[], wchar_t *envp[]) get_caps(caps_str, cap_clipboard, cap_no_kill); // args - auto args = args_pattern; - wstring passed_arg; for (int i = 1; i < argc; i++) { @@ -59,11 +57,19 @@ int wmain(int argc, wchar_t* argv[], wchar_t *envp[]) passed_arg += argv[i]; } - // do token replacement regardless of whether we have an argument or not - if we do, it needs to be deleted anyway - size_t pos = args.find(CMD_TOKEN); - if (pos != string::npos) + auto args = args_pattern; + if (args.empty()) + { + args = passed_arg; + } + else { - args.replace(pos, CMD_TOKEN.size(), passed_arg); + // do token replacement regardless of whether we have an argument or not - if we do, it needs to be deleted anyway + size_t pos = args.find(CMD_TOKEN); + if (pos != string::npos) + { + args.replace(pos, CMD_TOKEN.size(), passed_arg); + } } wstring full_cmd = image_path;