Skip to content

Commit

Permalink
Pass arguments by default if there is no custom arguments
Browse files Browse the repository at this point in the history
This is a fix of issue aloneguid#7
  • Loading branch information
mnivet committed Jun 28, 2023
1 parent 4b0bb5e commit 0fe933c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions shim/shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,26 @@ 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++)
{
if (i > 1) passed_arg += L" ";
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;
Expand Down

0 comments on commit 0fe933c

Please sign in to comment.